1. Connect UNO-1 and UNO-2 as per Fig-1.
Figure-1:
2. Upload the following sketches to transmit <A,B,234,567> from UNO-1 to UNO-2 and receive the same string by UNO-2. The SM2 shows: A, B, 234, 567. The data items are saved in variables:
char y1;
char y2;
int y3;
int y4;
UNO1/TX Sketch:
#include<SoftwareSerial.h>
SoftwareSerial SUART(A4, A5); //SRX = A4, STX = A5
char y1 = 'A';
char y2 = 'B';
int y3 = 234;
int y4 = 567;
void setup()
{
Serial.begin(9600);
SUART.begin(9600);
}
void loop()
{
SUART.print('<'); //start mark
SUART.print(y1); //data for LED1
SUART.print(','); //seperator
SUART.print(y2); //data for LED2
SUART.print(','); //start mark
SUART.print(y3, DEC); //data for ScoreBoard 1
SUART.print(','); //seperator
SUART.print(y4, DEC); //data for ScoreBoard 2
SUART.print('>'); //end mark
delay(1000);
}
UNO-2/RX Sketch:
#include<SoftwareSerial.h>
SoftwareSerial SUART(A4, A5); //SRX = A4, STX = A5
char myData[30];
char *token;
void setup()
{
Serial.begin(9600);
SUART.begin(9600);
}
void loop()
{
byte n = SUART.available();
if (n != 0)
{
char ch = SUART.read();
if (ch == '<') //start mark found
{
byte m = SUART.readBytesUntil('>', myData, sizeof myData - 1);
myData[m] = '\0'; //null-charcater
Serial.println(myData);
//--------------------------
token = strtok(myData, ",");
char y1 = *token;
Serial.println(y1); //y1 = A
//-------------------------
token = strtok(NULL, ",");
char y2 = *token;
Serial.println(token); //y2 = B
//-------------------------
token = strtok(NULL, ",");
int y3 = atoi(token);
Serial.println(y3, DEC); //234
//-------------------------
token = strtok(NULL, ",");
int y4 = atoi(token);
Serial.println(y4, DEC); //567
}
}
}
3. Connect LED1 with a 2.2k series resistor at DPin-4 of UNO-2 and conditionally use the value of y1 to control the On/Off state of LED1.
4. Connect LED2 with a 2.2k series resistor at DPin-5 of UNO-2 and conditionally use the value of y2 to control the On/Off state of LED2.
5. Connect 4-digit cc-type 7-segment display unit (Score Board 1) as per Fig-2 and show the value of y3 of Step-2. Add codes with the sketches of Step-2 to show 234 on DP1-DP3 of display unit.
Figure-2:
6. Add four more cc-type 7-segment display devices with Fig-2 to form Score Board 2 (Fig-3, DP4 - DP7). Add codes with the sketches of Step-2 to show 567 on DP4-DP7 of display unit.
Figure-3: