Alternative Serial Communication Between Two Arduino's

by dopke13 in Circuits > Arduino

417 Views, 1 Favorites, 0 Comments

Alternative Serial Communication Between Two Arduino's

fptserial.png

There are mainly 3 different ways for serial communication between arduino's, uart, i2c and spi. I made another one, just for fun.

It uses three wire's, two for data and one for control.

The state of the second dataline is multiplied by two, so the sum of the two datalines is a number from 0-3.

There are three sets in one cycle, the first is when de controlline is low, the second is when the controlline is high, and the third is when at least one the state changes while the controlline is high(see the example above),
the first two is for generating numbers from 0 to 9, while the third is for positioning: hunderds, tens and units, so that gives an output from 0-999 in three cycles(794 in the example).

To speed up, the hunderds and tens will be passed when they don't change.
The speed is controlled by the sender, the reciever waits for the units to recief and then calculate the sum.

Supplies

two arduino boards.

for the sender: can be anything as long as the voltage matches with the reciever,

for the reciever: any board with more then two interrupt pins, in this case mega2560, in other cases maby you must change the pin numbers and wires.

5 jumper wires.

Upload the Code's

I assume that you are already familiar with arduino's ( if not, go to https://www.arduino.cc/en/Guide and click on arduino docs and Get started with Arduino).

So copy the sendercode to one board and the recievercode to the other one and disconnect from the pc.

Wire the Board's

unomegaserial.png

Wire the boards as shown in image above, and connect the reciever to the pc, open the serial monitor (set baud rate at 9600), reset* the sender and look what happens, the numbers counts from 0 to 999 and start again from 0.

*reset the sender or else the tens and or the hunderds can be wrong before update from the sender at start,
this can be provide by disable the lines point out by # in the sendercode, but it will slow down the speed about 2,5 times.

Whats Next

Of course you can connect a potentiometer or a sensor to the sender or add the code in an other project (maybe you need to adjust the cycle speed by changing de value int j in the sendercode).

Advantages are numbers up to 999, adjustable speed, stable (tested with 60 meter long unshielded wires).

disavantage: its only unidirectional.

I use it in a project where uart works not properly,

Thanks for reading and/or trying this instructable, maybe it will be usefull for someone.