/*
Arduino - Lesson 4. Serial Monitor

Turns on an LED on for one second, 4 with different resistors so the LED brightess will change.

This example code is in the public domain.

modified 03 mar 2016
by www.avrprojects.net
*/

void setup()
{
Serial.begin(9600);
Serial.println("Enter LED Number 1 to 4 or 'x' to clear");
}

void loop()
{


if (Serial.available())
{
char ch = Serial.read();
if (ch >= '1' && ch <= '4')
{
int led = ch - '0';
digitalWrite(led + 1,HIGH);
Serial.print("Turned on LED ");
Serial.println(led);
}
else
{
Serial.println("Enter LED Number 1 to 4 or 'x' to clear");
}

if (ch == 'x')
{
int x = 2;
while(x <= 5)
{
digitalWrite(x,LOW);
x = x + 1;
}
Serial.println("Cleared");
}
}
}