Académique Documents
Professionnel Documents
Culture Documents
/*
-----------------------------------------------------------------------InfidelFish
-----------------------------------------------------------------------*/
String voice;
#define relay1 2
#define relay2 3
void setup()
{
Serial.begin(9600);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
digitalWrite(relay1, LOW);
//Switch relay1 of
digitalWrite(relay2, LOW);
//Swtich relay2 of
}
void loop()
{
while(Serial.available())
{
delay(10);
char c = Serial.read();
if (c == '#'){
break;
}
voice += c;
}
if (voice.length() >0)
{
Serial.println(voice);
if(voice == "*switch on"){
switchon();
}
{
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
}
void switchof()
{
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
}
/*
You can add any function you want depending on how many devices you have hooked up.
For example you could have a function called 'cinema' which would dim the lights and
turn the TV on. You can have as many as you have pins on your arduino.
For my relay 'LOW' turns of and 'HIGH' turns on
The outline to follow is this:
void ......()
{
digitalWrite(...., LOW/HIGH);
digitalWrite(...., LOW/HIGH);
}
*/