Tuesday 3 June 2014

Multiple Serial Ports

Exploring Multiple Serial Ports Using Arduino Mega.


I searched around for this because i will need to use it in future projects, at the moment i'm gearing up to build a mobile platform- wouldn't it be nice if it could map a room using sonar data... Anyway i found this excellent blog that explains it nearly perfectly apart from the TX to RX bit in step one, just beware, if you don't know what i'm on about I've made a comment at the bottom of his post.

Using a USB to serial TTL cable allows another serial port to be connected to a PC from the mega. 

USB To TTL Cable 

The mega has 4 possible ports to utilize. The green is TX and should be connected to RX on the board the white is RX and should be connected to TX on the board, red is power and is optional (5V external) and black is ground. the USB is simply connected to a port on the PC.

Ive put together a sketch that reads an LDR and prints the value to one serial port whilst the other port is used to keep track of when an led (the on board one connected to pin 13) is turned on and off using a button.

Resistors 10K (theres one behind the LDR)

To view two serial monitors in the arduino IDE open a fresh arduino program and set that to the serial port of your cable, or use Tera Term.

Com7 Showing LDR Values Com9 showing that switch is off


No comments:

Post a Comment