I am actually getting the hang of this programming thing!
Here is a 40 sec. demo of my rudimentary KB hacking....
And just in case anyone is interested in the code.
Code:
/*
Robotics with the BOE Shield – ServoRunTimes_withTurnSignals
Performing tight Left and Right turns with LED signaling.
*/
#include <Servo.h> // Include Servo Library
Servo servoLeft; // Declare Left Servo Signal
Servo servoRight; // Declare Right Servo Signal
void setup() // Built-in initialization block
{
servoLeft.attach(13); // Attach Left Servo to pin 13
servoRight.attach(12); // Attach Right Servo to pin 12
pinMode(11, OUTPUT); // Set Digital Pin 11 -> Output
pinMode(10, OUTPUT); // Set Digital Pin 10 -> Output
Start:
Left_Turn:
for(int l = 1; l <= 3; l++)
{
digitalWrite(11, HIGH); // Pin 11 = 5 V, LED emits light
delay(500); // ..for 0.50 seconds
digitalWrite(11, LOW); // Pin 11 = 0 V, LED no light
delay(250); // ..for 0.25 seconds
}
delay(500); // ..for 0.75 seconds
servoLeft.writeMicroseconds(1300); // Pin 13 PWM Clockwise Signal
servoRight.writeMicroseconds(1300); // Pin 12 PWM Clockwise Signal
delay(3000); // ..for 3 seconds
Break1:
servoLeft.writeMicroseconds(1500); // Pin 13 PWM Stay Still Signal
servoRight.writeMicroseconds(1500); // Pin 12 PWM Stay Still Signal
digitalWrite(11, HIGH); // Pin 11 = 5 V, LED emits light
digitalWrite(10, HIGH); // Pin 10 = 5 V, LED emits light
delay(1000); // ..for 1.0 seconds
digitalWrite(11, LOW); // Pin 11 = 0 V, LED no light
digitalWrite(10, LOW); // Pin 10 = 0 V, LED no light
delay(1000); // ..for 1.0 seconds
Right_Turn:
for(int r = 1; r <= 3; r++)
{
digitalWrite(10, HIGH); // Pin 10 = 5 V, LED emits light
delay(500); // ..for 0.50 seconds
digitalWrite(10, LOW); // Pin 10 = 0 V, LED no light
delay(250); // ..for 0.25 seconds
}
delay(500);
servoLeft.writeMicroseconds(1700); // Pin 13 PWM CounterClockwise Signal
servoRight.writeMicroseconds(1700); // Pin 12 PWM CounterClockwise Signal
delay(3000); // ..for 3 seconds
Break2:
servoLeft.writeMicroseconds(1500); // Pin 13 PWM Stay Still Signal
servoRight.writeMicroseconds(1500); // Pin 12 PWM Stay Still Signal
digitalWrite(11, HIGH); // Pin 11 = 5 V, LED emits light
digitalWrite(10, HIGH); // Pin 10 = 5 V, LED emits light
delay(1000); // ..for 1.0 seconds
digitalWrite(11, LOW); // Pin 11 = 0 V, LED no light
digitalWrite(10, LOW); // Pin 10 = 0 V, LED no light
delay(1000); // ..for 1.0 seconds
goto Start; // sends program flow to Start
}
void loop() // Main loop auto-repeats
{ // Empty, nothing needs repeating
}
I know, I know, Using a goto was unnecessary as I could have just put most of the code into the "void loop()" function declaration section. I just like goto statements.