int led = 13;
void setup()
{
Serial.begin(9600);
pinMode(led,OUTPUT);
digitalWrite(led,LOW);
}
void loop()
{
if(Serial.available())
{
String value = Serial.readStringUntil('\n');
Serial.println(value);
if(value == "on")
{
digitalWrite(led,HIGH);
}
else if(value == "off")
{
digitalWrite(led,LOW);
}
}
}
code for control arduino by voice from your phone:
int led = 13;
void setup()
{
Serial.begin(9600);
pinMode(led,OUTPUT);
digitalWrite(led,LOW);
}
void loop()
{
if(Serial.available())
{
String value = Serial.readStringUntil('\n');
Serial.println(value);
if(value == "*hello#")
{
digitalWrite(led,HIGH);
}
else if(value == "*1#")
{
digitalWrite(led,LOW);
}
}
}
No comments:
Post a Comment