Serial port interface prep work

I really want to get a grip on serial communication. Step one is to set up something to read from or send to. I had hoped that it would be similar to how web servers worked – I can set up a web server on my local PC and then connect to it on the same PC. Very convenient for testing. I can’t find a way to set up a software process that emulates a serial port for me to send/receive data with. Lucky for me I have an Arduino Uno.

Here’s the Arduino sketch:

void setup() {
 // initialize the digital pin as an output.
 // Pin 13 has an LED connected on most Arduino boards:
 pinMode(13, OUTPUT);

void loop() {
 digitalWrite(13, HIGH); // set the LED on
 Serial.println("Hello World");
 delay(1000); // wait for a second
 digitalWrite(13, LOW); // set the LED off
 delay(1000); // wait for a second

This sketch blinks an LED on the Arduino breakout board and outputs serial data. I included the blinking as a way to confirm the chip is doing something. I hadn’t realized there’s an LED that blinks when it sends serial data so it wasn’t super necessary to do it myself. That’s ok.

Cool, so I uploaded the program to the chip and confirmed with the built in serial monitor that it’s outputting something. Now I want to see if I can “connect” to it (or “monitor”, not sure what the correct term is here) using some other program. I found a forum post that mentioned using a program called screen to do this. In the terminal I type:

>>screen /dev/ttyACM0 9600

And I do indeed get “Hello World” printed once every two seconds. The problem is that there  doesn’t seem to be a way to exit screen. Another search later and I popped open another terminal session and typed:

>>screen -ls

which told me the name of the screen session open, and I stopped it using:

>> screen -X -S 21044.pts-0.chris-Ubuntu1204 quit

I’m not sure what that did, exactly, but it worked.

My mission this morning is accomplished. I now have a device that outputs serial communication, and I should be able to now experiment with receiving that data. Once I get that working I’ll move on to sending data. The end goal is to send information over the serial line to the Arduino to control the program running on the chip itself.

This entry was posted in Hobbies, Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s