Hy!
I have made a Code for LED blink speed manipulating with Potentiometer. The blinking started only if I send "start" command and will end if I send "stop".
And now i would like this controlling with numbers 1-255 achieve. How can i send any numbers via Serial(not only 0-9)?
int led=13;
int potpin=5;
byte ch;
String stringone,stringtwo,stringin;
int speedszam;
void setup()
{
Serial.begin(9600);
pinMode(led,OUTPUT);
stringone= String("start");
stringtwo= String("stop");
speedszam= analogRead(potpin);
}
void loop()
{
ch=0;
stringin='\0';
while (Serial.available())
{
ch=Serial.read();
stringin+=(char)ch;
delay(1);
}
if (stringin==stringone)
{
while(stringin != stringtwo)
{
speedszam= analogRead(potpin);
digitalWrite(led,HIGH);
delay(speedszam);
digitalWrite(led,LOW);
delay(speedszam);
ch=0;
stringin='\0';
while (Serial.available())
{
ch=Serial.read();
stringin+=(char)ch;
delay(1);
}
}
}
}