Moving a dc motor shaft to 90 degrees


i'm doing project light detector, using arduino  but i'm restricted in having h-bridge transistor circuit (not chip h-bridge). projects concept able give direction motor side there higher intensity of light (which read via photoresistors). example if photo resistor on left has more light intensity motors shaft should turn 90 degrees left , original place, , same thing if right photo resistor on right. if both of them have around same level of intensity, should stay on original position.

however doing code motor (as testing know how implement later) while repeats movement of 90 degrees right found out moving bit more should, resulting on having same movement until cover 360 degrees. can me fix problem? here code:

void setup() {
 // put setup code here, run once:
int runmotorr;
int runmotorl;
pinmode(7,output);
pinmode(8,output);
}

void loop() {
 // put main code here, run repeatedly:
runright();
//runleft();

}


void runright(){

digitalwrite(8,high);
digitalwrite(7,low);
delay(480);
digitalwrite(8,low);
digitalwrite(7,low);

while(millis() < 900){
 digitalwrite(8,high);
 digitalwrite(7,low);
 }

digitalwrite(7,high);
digitalwrite(8,low);
delay(480);
digitalwrite(8,low);
digitalwrite(7,low);
}


void runleft(){
digitalwrite(8,low);
digitalwrite(7,high);
delay(100);
digitalwrite(8,high);
digitalwrite(7,high);

//while() //para que el motor se quede detenido apuntando el lado que percibe mas luz

digitalwrite(7,low);
digitalwrite(8,high);
delay(100);
digitalwrite(8,high);
digitalwrite(7,high);
}

you'll need kind of sensors software knows when motor in 3 stop positions.   slotted optical sensors common solution.


Arduino Forum > Using Arduino > Project Guidance > Moving a dc motor shaft to 90 degrees


arduino

Comments

Popular posts from this blog

Error compiling for board Arduino/Genuino Uno.

Installation database is corrupt

esp8266 (nodemcu 0.9) client.write très lent ???