Sunday, October 30, 2016

Easy Chat Program using Arduino.

Good evening everyone. So in this day of age anyone who is interested in electronics or keep an eyes on technological news Arduino should be a very common word for them and rightly so because it has made designing and implementing circuits so simple that even amateur people can actually make awesome things this days. Arduino has pretty much gave everyone the power to make something which was previously kinda on the hands of people who knows about how things work. Anyway you can already guess this post will be something using Arduino and it is a simple chat program.

So what this will allow us to do is just send and receive simple text from a computer. Yes I understand there are much better options out there but this one will help you to get familiarized with Arduino and show you how easy it is to get things done.

Parts needed: 

1. A pair of Arduino. I'm using the ever popular and cheap Arduino UNO.
2. A pair of USB Type A to Type B cables to connect Arduino with computers.
3. Two Male to Male jumper wire or similar cable to connect the Arduinos.
4. Arduino IDE on computers.


1. In this particular example I'm using the Arduino pins 7 and 8 but you can use any pin you want all you have to do is to change the code accordingly. I have used 7 and 8 because they are easy to find. Just connect pin 7 of one Arduino to pin 8 of the other. So there will be two wires connecting both the Arduinos.

2. Make sure the IDE is installed on your computer, it can be downloaded from their website for free.

3. Connect the Arduino via USB port and upload the Code found in the Direct Chat Code file, link will be on the bottom of this post. You need to put the exact same code in both of them. Make sure to select the correct COM port before uploading.

4. Now open up serial monitor and you can start chatting.

The Code:

/* Simple Chat Program

 Receives from the hardware serial, sends to hardware & software serial.
 Receives from software serial, sends to hardware serial.

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

 Created and modified by Redwan Hasan based of software serial example.
#include <SoftwareSerial.h>

SoftwareSerial chat(10, 11); // Define RX, TX

int text;

void setup() 
  // open hardware serial, TX = 1, RX = 0
  Serial.println("Welcome to the chat program...");
  // set the data rate for the SoftwareSerial port

  // delay 1s to stabilize serial ports

  chat.println("Your Friend is online");

void loop()
  if (chat.available())
  if (Serial.available())
    while (Serial.available())
      text =;

Here is the project.

Working Circuit for this project

So how does it work?

The basic idea is very simple here, the pin 7 is the RX pin and 8 is the TX pin. The way we have connected them is from TX to RX and RX to TX. What's gonna happen is this, what one is transmitting other will simply receive it and put it on display and as the path is bi-directional anyone can send and receive.


Here it is, a bi-directional conversation can be done here. I have used one a single computer to connect both the Arduinos but you can use two computers and essentially chat with someone else.

Hope it has helped.


1. Arduino webpage.
2. Read my other posts.