0% found this document useful (0 votes)
2 views

Bluetooth Com Arduino

The document contains an Arduino sketch for controlling three lamps in different rooms: sala, quarto, and cozinha. It sets up the pins for output and listens for serial input to turn the lamps on or off based on specific character commands. The commands 'a' to 'f' correspond to turning the lamps on and off respectively.

Uploaded by

Paulo Oliveira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Bluetooth Com Arduino

The document contains an Arduino sketch for controlling three lamps in different rooms: sala, quarto, and cozinha. It sets up the pins for output and listens for serial input to turn the lamps on or off based on specific character commands. The commands 'a' to 'f' correspond to turning the lamps on and off respectively.

Uploaded by

Paulo Oliveira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#define lampSala 13

#define lampQuarto 12
#define lampCozinha 11

char data;

void setup()
{
pinMode(lampSala, OUTPUT);
pinMode(lampQuarto, OUTPUT);
pinMode(lampCozinha, OUTPUT);
digitalWrite(lampSala, LOW);
digitalWrite(lampQuarto, LOW);
digitalWrite(lampCozinha, LOW);
Serial.begin(9600);
}

void loop()
{
if (Serial.available() > 0)
{
data = Serial.read();
switch (data)
{
case 'a' : digitalWrite(lampSala, HIGH);
break;
case 'b' : digitalWrite(lampSala, LOW);
break;
case 'c' : digitalWrite(lampQuarto, HIGH);
break;
case 'd' : digitalWrite(lampQuarto, LOW);
break;
case 'e' : digitalWrite(lampCozinha, HIGH);
break;
case 'f' : digitalWrite(lampCozinha, LOW);
break;
}
}
delay(50);
}

You might also like