this is my second problem today, is that normal?
anyhow, for some reason my robot turns left fine(2 driveleft==90 degrees, 2 driveright is SUPPOSED to be 90 degrees too) but right turns, it just jults, as if there is some problem with the loop system. my code is very complex, because out of boredom i decided to code an OS, for the actual code that runs the robot, so i will give all the important bits:
the main, robot code:
void mainrun()
{
if(dist>myread(1,250)) { //wall nearby
collect();//colect sensor data
decide();
Lset(2);//set directions
Rset(1);//in witch to drive/continue driving
}else{
drive();//continue forward
}
}
the collect:
void collect()
{
driveright();
driveright();
leftside=analogRead(A0);
driveleft();
driveleft();
driveleft();
driveleft();
rightside=analogRead(A0);
//note-robot still faces right!
}
the driveright:
void driveright()
{
Lset(2);//set directions
Rset(2);//in witch to drive
for(times=0;times<myread(2,100);times++)
{
drive();//drive for duration
//delay(300);
}
Lset(0);//set directions
Rset(0);//in witch to drive/stop
delay(500);
drive();//stop
}
the code for drive left is precicely the same, exept Lset and Rset are both 1 instead of 2. i checked by copying driveleft and changing those 2, but it didnt work.
drive code:
void drive()
{
switch (Lstatus) {
case 1:
Lfront();
break;
case 2:
Lback();
break;
}
switch (Rstatus) {
case 1:
Rfront();
break;
case 2:
Rback();
break;
}
}
finaly, Rback/front:
void Rback()
{
digitalWrite(Rmotpin,HIGH);
delayMicroseconds(0010);
digitalWrite(Rmotpin,LOW);
}
Rfront is the same, but the delay is 2000, and Lfront/back has Rmotpin swapped with Lmotpin.
wow I have a lota code. I hope I have enough code for you to find the problem, yet not so much so you will actually reply