#include Servo feedServo; // create servo object to control a servo void feedRaw(){ static int pos, wait; wait=15; for(pos = 80; pos < 160; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree feedServo.write(pos); // tell servo to go to position in variable 'pos' delay(wait); // waits 15ms for the servo to reach the position } for(pos = 160; pos>=80; pos-=1) // goes from 180 degrees to 0 degrees { feedServo.write(pos); // tell servo to go to position in variable 'pos' delay(wait); // waits 15ms for the servo to reach the position } } void setup() { Serial.begin(9600); // start serial port at 9600 bps and wait for port to open feedServo.attach(9); } void loop(){ while (Serial.available() <= 0) { delay(1500); Serial.println("Are you there? If so type 'y' and hit [enter/return]"); // send a capital A delay(3000); } // initialize the LED pin as an output: const int ledPin = 13; pinMode(ledPin, OUTPUT); if (Serial.available() > 0) { // if we get a valid byte, get incoming byte: char answer; int inByte = Serial.read(); if (inByte=='y') { Serial.println("Thank you for using the Fab-Launcher for your training"); Serial.print("Beginning setup. Please be patient"); delay(1500); Serial.print("."); delay(1500); Serial.print("."); delay(1500); Serial.print("."); delay(1500); Serial.print(".");//Completely pointless waiting time delay(1500); Serial.print("."); delay(1500); Serial.print("."); delay(1500); Serial.print("."); delay(1500); Serial.println("."); Serial.println("To begin using the Fab-Launcher, you will need to select options for your game training. "); Serial.println("YOU ARE HERE TO PLAY PING-PONG CORRECT? If so, type 'y' and hit [enter/return]"); while(Serial.available() <= 0){delay(150);} answer = Serial.read(); if (answer=='y') { // turn LED on: digitalWrite(ledPin, HIGH); feedSetup(); delay(1500); digitalWrite(ledPin, LOW); //turn LED off } else{Serial.println("What? I can't help you");} delay(1500); } } delay(500); feedRaw(); delay(500); feedRaw(); }