Skip to content

Instantly share code, notes, and snippets.

@lucabelluccini
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucabelluccini/634ac94bc11a8ef8f9f5 to your computer and use it in GitHub Desktop.
Save lucabelluccini/634ac94bc11a8ef8f9f5 to your computer and use it in GitHub Desktop.
Parallax Continuous Servo example (http://www.parallax.com/product/900-00025)
#include <Servo.h>
// Parallax Continuous Servo example (http://www.parallax.com/product/900-00025)
// Read values from serial and set the speed of the servo
// Range 0 to 180; 90 is no movement
// Remember to set the proper baud rate and carriage return settings
Servo theServo;
int gSpeed = 90;
void setup()
{
Serial.begin(9600);
theServo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
while (Serial.available() > 0) {
gSpeed = Serial.parseInt();
if (Serial.read() == '\n') {
gSpeed = constrain(gSpeed, 0, 180);
Serial.print(gSpeed, HEX);
theServo.write(gSpeed);
}
}
delay(20);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment