Advertisement
Guest User

Untitled

a guest
Jan 30th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.18 KB | None | 0 0
  1. #include "simpletools.h"              //Include simpletools header
  2. #include "servo.h"                    //Include servo header
  3.  
  4. int main()                            //main function
  5.   {
  6.   servo_angle(17, 1800);              //Servo to 180 degrees          
  7.   pause(2000);                        //Wait for 2 seconds        
  8.   servo_angle(17, 0);                 //Servo to 0 degrees      
  9.   pause(1000);                        //This pause was during movement, not sure how to only have 1
  10.   pause(1000);                        //This is the one that actually pauses. If it's not here, it doesn't pause                  
  11.   servo_angle(17, 1800);              //Servo to 180 degrees        
  12.   pause(4500);                        //Wait for 4.5 seconds
  13.   high(26);                           //LED 26 ON
  14.   pause(100);                         //Wait 10ms      
  15.   low(26);                            //LED 26 OFF      
  16.   pause(500);                         //Wait half second                          
  17.   servo_angle(17,900);                //Servo to 90 degrees
  18.   blink();                            //Calls the blink function *IT'S ALIIIIVE!!!*
  19.   servo_stop();                       //Stop servo
  20.   }
  21.  
  22.  
  23.  
  24.  
  25. void blink(void)                      //blink function
  26.   {
  27.     high(27);                         //This is a test, I want to see if I can avoid
  28.     pause(50);                        //putting 15 lines of blink code in main() to make it look nicer
  29.     low(27);                          //Result, it works...and looks nicer.
  30.     pause(50);                        //Now, I'd LIKE to know how to have a blink sequence that does an
  31.     high(27);                         //On/Off for as long as the motor is running, rather than "cheating"
  32.     pause(50);                        //and trial an erroring the number of blinks it would take to blink
  33.     low(27);                          //during the duration of the rotation.
  34.     pause(50);                        //This function SHOULD be 4 lines, high/pause/low/pause then repeat
  35.     high(27);                          
  36.     pause(50);
  37.     low(27);
  38.     pause(50);
  39.     high(27);
  40.     pause(50);
  41.     low(27);                      
  42.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement