Skip to content

14. Networking and communications

▶ Group assignment ✌

  • Send a message between two projects.

In This week’s group assignment is to send a message between two projects. I’m the only student this year, so I need to borrow my instructor board the one he designs and mill it in input-devices assignment week.

UART (Universal Asynchronous Receiver-Transmitter)

I’m starting with reading his schematic to understand and know the pins

Bridge & Nodes

Now I arrange my boards and wires The board I will use it as bridge and the board I will use it as Nodes.

during my work, I lose the right connection of the wires and I’m losing more time I decide to color my pins I think it’s a funny way but it works and saves my time.

Connection

Now I made my connection and I do a quick test with push-button to be sure all the connection is right and all My LEDs work but the LED in the node1 does not turn ON after along long, long :)! check I find out

the wire jumper was loose so I decide to use another GND Pin

I replace the LED connection for my Instructor connection with a Female header connector

The Code

Node Sample The number after “const char node” has been changed for different nodes.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3); // RX, TX (The ATTiny Pin number, NOT the board Pin number)

const char node = '1'; // network address
const int ledPin = 1; // the number of the LED pin

int incomingByte;
void setup() {
mySerial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(3, INPUT);
}

void loop() {
if (mySerial.available() > 0) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
incomingByte = mySerial.read();
if (incomingByte == node) {
digitalWrite(ledPin, HIGH);
pinMode(3, OUTPUT); // open line to write
mySerial.print("node ");
mySerial.println(node);

pinMode(3, INPUT);
delay(200);
digitalWrite(ledPin, LOW);
}

How its work

From the Arduino IDE, click on the serial monitor button. On the serial monitor window just type (1) that make LED ON and If you click (2) the LED turn OFF after press enter to make the action.

Final Result


Last update: July 26, 2022