11. Networking and Communications
This week was focused on Networking and Communications.
What I did
This week, the goal was to get two microcontrollers to communicate, so I got Kaz’s microcontroller to send a message to mine, which said “ Jadelyn is silly”. Kaz’s microcontroller is connected to his computer and has wires that connect to my controller, which is connected to my laptop. The White wire goes to GND, and the orange and blue wires go to outputs 7 and 8. Outputs 7 and 8 have TX and RX, which send and receive messages.

Code
This first code was used on Kaz’s laptop, and it sent the message “Jadelyn is silly”
void setup() {
// Start Serial1 for TX/RX communication
Serial1.begin(9600);
}
void loop() {
// Send a message
Serial1.println("jadelyn is silly!");
delay(1000); // send every second
}
The second code that was on my laptop is receiving the message
void setup() {
// Start USB Serial for debug output
Serial.begin(9600);
// Start Serial1 for receiving messages
Serial1.begin(9600);
}
void loop() {
if (Serial1.available()) {
String msg = Serial1.readStringUntil('\n');
Serial.println("Received: " + msg);
}
}
In action
Once everything is connected, Kaz’s microcontroller sends the message every second
Group Work
For group work we were practicing having communication between two arduinos unos. We connected the two with wires. Then using the code on each computer it would allow us to send messages to each other. We were able to basically text between each computer. The only downside is that after we sent the message we couldn’t see the text we sent.