Serial.begin(9600) for usb
Serial1.begin(9600) for RX and TX
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(2, INPUT); // set the pushbutton pin to be an input
pinMode(13, OUTPUT); // set the yellow LED pin to be an output
pinMode(12,INPUT);
}
void loop() {
// read the pushbutton input:
if (digitalRead(12) == HIGH) {
// if the pushbutton is closed:
digitalWrite(13, HIGH); // turn on the yellow LED
}
else {
digitalWrite(13, LOW); // turn off the yellow LED
}
}
String data;
void setup(){
Serial.begin(9600); //USB SERIAL
Serial1.begin(9600); //RX TX Pins Serial
}
void loop(){
if(Serial.available() > 0){
data = Serial.readString();
if(data == "ON"){
Serial1.println('1');
Serial.println("LED IS ON");
} else if (data == "OFF"){
Serial1.println('0');
Serial.println("LED IS OFF");
}
}
}
Transmitter for the lights (ADD VIDEO)
String data;
void setup() {
Serial.begin(57600); //USB SERIAL
Serial1.begin(57600); //RX TX Pins Serial
}
void loop() {
if (Serial.available() > 0) {
data = Serial.readString();
if (data == "JULIA") {
Serial1.println('J');
Serial.println("JULIA LED IS ON");
} else if (data == "LIAM") {
Serial1.println('L');
Serial.println("LIAM LED IS ON");
} else if (data == "ALYSSA") {
Serial1.println('A');
Serial.println("ALYSSA LED IS ON");
} else if (data == "FABRI") {
Serial1.println('F');
Serial.println("FABRI LED IS ON");
} else if (data == "FABRIOFF") {
Serial1.println('0');
Serial.println("OFF");
} else if (data == "JULIAOFF") {
Serial1.println('1');
Serial.println("OFF");
} else if (data == "ALYSSAOFF") {
Serial1.println('2');
Serial.println("OFF");
} else if (data == "LIAMOFF") {
Serial1.println('3');
Serial.println("OFF");
} else if (data == "ALLOFF") {
Serial1.println('4');
Serial.println("ALLOFF");
} else if (data == "ALLON") {
Serial1.println('5');
Serial.println("ALLON");
}
}
}
We made the Arduinos communicate and control the LEDs for each person, turning them on and off.