blue book examples

This commit is contained in:
benfry
2011-01-26 20:26:16 +00:00
parent a5fb67810a
commit cd888bc239
927 changed files with 36898 additions and 0 deletions
@@ -0,0 +1,19 @@
// Read data from the serial port and set the position of a servomotor
// according to the value
Servo myservo; // Create servo object to control a servo
int servoPin = 0; // Connect yellow servo wire to digital I/O pin 0
int val = 0; // Data received from the serial port
void setup() {
myservo.attach(servoPin); // Attach the servo to the PWM pin
Serial.begin(9600); // Start serial communication at 9600 bps
}
void loop() {
if (Serial.available()) { // If data is available to read,
val = Serial.read(); // read it and store it in val
}
myservo.write(val); // Set the servo position
delay(15); // Wait for the servo to get there
}