Advertisement
nickmcski

Arduino drive code

Jan 10th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. /*
  2. ============Drive===========
  3. = Made By: Nicholas McCurry=
  4. =      Free public use     =
  5. */
  6. //This is the pin the circut is pluged in
  7. int reverse = 13;
  8.  
  9.  
  10. void setup() {                
  11.   // initialize the digital pin as an output.
  12.   pinMode(reverse, OUTPUT);    
  13. }
  14.  
  15. void loop() {
  16.   digitalWrite(reverse, HIGH); //Reverses motor direction
  17.   delay(3000); //How long to go this direction
  18.   digitalWrite(reverse, LOW);  //Sets it back to normal direction
  19.   delay(500);  //How long to go this direction
  20. /*Change  i < 10 to change how long it stays still */
  21.   for(int i = 0; i < 10; i++){
  22.     //This is ment to go forward and back really quick
  23.     //mimicing the robot stoping
  24.     digitalWrite(reverse, LOW);
  25.     delay(30);
  26.     digitalWrite(reverse, HIGH);
  27.     delay(30);
  28.   }    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement