Exercise 13

29.04.2015

Networking and Communications

Assignment

design and build a wired &/or wireless network connecting at least two processors


FabChat

With my friend Pierluigi we decided to make a serial chat in order to chat via Serial with two satshakit.
the project is very simple but we learned how to use software and hardware serial between 2 microcontrollers.

this is the schematic to link 2 microcontroller
s
And this is the simple sketch that we write to adapt the SoftwareSerial example to our project

/*
Fab Academy 2015
Networking communication
Gianluca Pugliese
Pierluigi De Palo

Chat Program between 2 satshakit
 

The circuit:
* RX is digital pin 10 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)
 

based on SoftwareSerial 
*/


#include <SoftwareSerial.h>
 
SoftwareSerial chat(10, 11); // RX, TX
 
int text;
 
void setup()
{
     // open hardware serial, TX = 1, RX = 0
     Serial.begin(9600);
     Serial.println("Fab chat is starting...");
     // set the baudrate
     chat.begin(9600);
     delay(1000); // delay 1s to stabilize serial ports
     chat.println("connected! start to chat");
}
 
void loop()
{
     if (chat.available())
          Serial.write(chat.read());
 
     if (Serial.available())
     {
          Serial.print("Gianlu: ");
           chat.write("Gianlu: ");
          while (Serial.available())
          {
               text = Serial.read();
              
               chat.write(text);
               Serial.write(text);
          }
          chat.println();
          Serial.println();
     }
}
The skatch start the serial monitor and wait until the other MCU is connected, than is possible to write text like a chat.
using Serial.print and Chat.write we can see our names during the chat
When the chat start the only things that we need to do is to reset the board in order to start the signal on the serial monitor.

Here a video of the FabChat between me and Pierluigi