Software > Software

Help Programming Arduino Uno

<< < (2/2)

robocreator:
I tried, thank you, do you know how to fix the sensor. Thanks for your help.

briselec:
// front servo
  for(pos = 0; pos < 1; pos += 1)  // goes from 0 degrees to 10 degrees
                                     // in steps of 1 degree
    myservo3.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5);                       // waits 15ms for the servo to reach the position
  for(pos = 0; pos>=1; pos-=1)     // goes from 10 degrees to 0 degrees
                                 
    myservo3.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5);                       // waits 15ms for the servo to reach the position
}

Have a closer look at the expressions in your for loops. Neither of them do as stated in the comments

robocreator:
OK, how do you suggest it should look like. I tried what the other said... I want to make it move, turn, stop, etc from the signal from the IR sensor.

jwatte:
Also, this code doesn't do what you think it does:


--- Code: ---SensorPin = (10, 20, 30, 40, 50, 60, 70, 80);

--- End code ---

It actually just assigns the value 80 to the variable SensorPin. The rest of the values are discarded by the comma operator.

I think you'd be well served by trying to learn C / C++ programming on a desktop computer, without a robot involved. Then you can step through the program in a debugger, and see what each line does, and compare it to what you think it should do -- a much faster way to learn!

If that's not an option for you, then I suggest cutting your program down to the smallest thing it can do. Then add one small feature at a time, and make it work before you move on to the next.

MrWizard:
http://www.computerscienceforeveryone.com/

Nice site and clear tutorials !

Navigation

[0] Message Index

[*] Previous page

Go to full version