Advertisement
Techmo

ArduinoServo

Feb 7th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <Servo.h>
  2. Servo servoMain;
  3. Servo servoSecond;// Define our Servo
  4. Servo servoThird;
  5. int pos = 0;
  6. void setup()
  7. {
  8.    servoMain.attach(12); // servo on digital pin 10
  9.    servoSecond.attach(11);
  10.    servoThird.attach(10);
  11.    Serial.begin(9600);
  12.    Serial.write("+--------------------------------------------------+\n");
  13.    Serial.write("|  Type any angle from '0' to '180' degrees into   |\n");
  14.    Serial.write("|    the serial monitor.                           |\n");
  15.    Serial.write("|                                                  |\n");
  16.    Serial.write("|  Bitrate:'9600'                                  |\n");
  17.    Serial.write("|  Program:'Servo_Control'                         |\n");
  18.    Serial.write("|                                                  |\n");
  19.    Serial.write("|                                                  |\n");
  20.    Serial.write("|                                                  |\n");
  21.    Serial.write("|                                                  |\n");
  22.    Serial.write("+--------------------------------------------------+\n");
  23. }
  24.  
  25. void loop()
  26. {
  27.  if(Serial.available() > 0)
  28. {
  29. pos = Serial.parseInt();
  30. }
  31. servoMain.write(pos);
  32. servoSecond.write(pos);
  33. servoThird.write(pos);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement