I have written a simple code to delay the blinking of LED 13, the delay time is set by us.I have incurred a problem when I enter a 2 digit value in the serial monitor.There is some problem with the ASCII. Is there a way to solve this problem without using Serial.parseInt()
.
void setup()
{
Serial.begin(9600);
Serial.println("Programming is starting");
pinMode(13,OUTPUT);
}
void loop()
{
if(Serial.available())
{
int val=Serial.read();
int val1=val-'0';
Serial.println(val1);
digitalWrite(13,HIGH);
delay(val1*1000);
digitalWrite(13,LOW);
}
}