Two Arduinos Talking To Each Other

2arduino Banner
I wanted to play with keypads so I went to look for one at Jalan Pasar, but unfortunately they all cost at least RM20. I just wanted something cheap to experiment with first. So, I asked the salesperson are there any keypads that are cheaper than those, she immediately reached for a shelve and took this out.

It’s a paper based keypad and it costs less than RM 7. Perfect for my needs. Another plus point about this keypad is I don’t need to solder any wires or headers on it.

It already comes with a female header and all I need to do is to plug in a male-to-male header into it. That will make it easier to be plugged into a breadboard.

Remember this circuit?

It’s the 7 Segment circuit from two posts ago. Now I plan to add in the keypad to display the digits according to what I press on the keypad.

Unfortunately, I ran out of digital pins. I didn’t expect this day to come so soon, I thought the Arduino Mega is overkill but now I understand why some people prefer it over the Uno.

From the picture, you might think that the pins are just enough. But actually it’s not. I’m already taking the first two digital pins which are RX and TX and they have 1k of resistance from the MCU’s pin.

Since I don’t have the luxury of owning a Mega, what I can do is to make use of my two Arduinos, the Uno and the Nano. I connected the keypad to the Nano and program it to talk to the Uno through serial communication.

Connecting it is pretty simple, the TX pin from the Nano goes to RX on the Uno and RX from the Nano goes to TX on the Uno. Basically just inverting them.

I also linked both the 5V and Ground together so that they can share the power source. All I need to do is to either power up the Nano or the Uno.

Here is the code I wrote for the Uno,

and the Nano,

Two Arduinos working hand in hand 🙂

And finally, here’s a demonstration video.

Thanks for reading 🙂

Print Friendly
  1. Foxfur11-15-2013

    Great article. Please post the code used in it. Thanks!

  2. Ming You11-26-2012

    If I wanna make a wireless communication between 2 Arduino, what should I do?

    • Wai Hung11-26-2012

      You can use two RF modules, a receiver and transmitter, like these

      These can only transmit a high or low signal, can’t transfer data like serial or i2c.

      • Ming You11-27-2012

        ok, thanks. how about the coding? isn’t is same with above?

        • Wai Hung11-27-2012

          Nope but the coding will be easier. What are you trying to achieve?

          • Ming You11-27-2012

            I want to build a wireless controller to control a mini-car. The controller will contain a ATmega8, a transmitter and 4 push switch. I don’t know how to write the coding for it. Do you have any suggestion?

            • Wai Hung11-27-2012

              I roughly have an idea. What do you use for the motor and steering? Simple dc motor and a servo?

              The dc motor goes through a h bridge?

              Maybe you can list down everything u have and intend to use.

              • Ming You11-27-2012

                okay. 2 simple DC motor, 1 L293DNE motor driver IC. I didn’t use servo motor. To turn left, I activate right motor and deactivate left motor. To turn right, I activate left motor and deactivate right motor. That’s all. In the coding, I just use digitalWrite.

                • Wai Hung11-27-2012

                  Just did a simple research on it and found out that you can actually send data through RF. Just need two MCU (one at each side).

                  Are you familiar in sending data to serial monitor?

                  If yes then it’s pretty much the same concept. Hook up both transmitter and receiver and the DATA pin on the module acts as a wireless bridge to the receiving MCU.

                  Just hook up the TX from the transmitting side and the RX from the receiving side.

                  Then the receiving MCU will receive data from the transmitting MCU just like as if you’re using the Arduino IDE’s serial monitor.

                  I found a similar project here :

  3. vick03-16-2012

    Nice..Wish to learn it too 🙂

    • waihung03-16-2012

      Just get an Arduino 🙂
      I find myself using the Arduino most of the time because the library is really complete.

Leave a Reply