Skip to content

Week 13 - Group assignment

We did some serial communication using the SoftwareSerial.h library, and getting inspired by the code provided by Adrian Torres on its documentation.

We were observing the information exchanged in the meantime in the real Serial monitor (from two different computers). We managed to observe the effect of the serial communication between the two arduino unos (lighting up the leds) but could'nt see consistent values in the serial monitors (probably a problem of format / byte).

Circuit pictures

Demonstration video

Code

//code made by Adrián Torres
//Fab Academy 2020
//Fab Lab León
//ATtiny412 bridge

#include <SoftwareSerial.h>
SoftwareSerial mySerial(12,13); //RX, TX
int v=0; 
int nodeid=1; //Node Identification
int i=0;

void setup() {
  mySerial.begin(115200); //initialize serial communications
  Serial.begin(115200); 
  pinMode(4, OUTPUT); // led
}

void loop() {
  for (i=1;i<=3;i++){ // initialization; condition; increment
  mySerial.println(i); // print value to Serial
  Serial.println(i);
  delay(1000);
  }

  while (mySerial.available () == 0 ) {}  //while serial is 0 
  v = mySerial.parseInt();
  if(v == nodeid)        //If the value of v equals the identification of the node
{
  digitalWrite(4,HIGH);
  delay(200);
  Serial.println("led high");
  digitalWrite(4,LOW);
  delay(200);
}
else
{
  digitalWrite(4,LOW);
  Serial.println("led low");
 }
}