/*
- serial_control.pde
- -------0
- Turns the LED 13 ON and OFF depending on what is received
- through the serial port.
- http://spacetinkerer.blogspot.com
*/#define LED 13
int LED2 = 12;int input = 0; // variable to keep the data from the serial port
void setup() {
pinMode(LED,OUTPUT); // declare the LED's pin as outputSerial.begin(9600); // connect to the serial port
}void loop () {
while(Serial.available()){
input = Serial.read(); // read the serial port// if the input is '1' turn the LED ON, if '0' turn it OFF
if (input == '1' ) {
Serial.println("LEDS are Now On");
digitalWrite(LED , HIGH);
delay(500);
digitalWrite(LED , LOW);}
else if(input == 0){
Serial.print("Program Terminated.");}
else{
Serial.println("Sorry, that is not a valid input.");
Serial.println("You tried inputing:");
Serial.println(input);
Serial.println("Valid Commands are 0 and 1.");
}
}}
The code won't go on a loop in the if statement, why?