Last week we started working on the serial communication. Yes, this means that we’ll start working on applications using both microcontroller and computer and finally can connect p5 and Arduino.

The first lab is kind of theoretical, everything worked for me, so I’ll just run through process and ask questions (a lot of them again).

First of all, as always, we need to prepare our breadboard and connect 2 analog and 1 digital sensor. I’m using 2 potentiometers and a simple witch. Here’s how it looks:

IMG_1454

The next thing I’m trying to do is read the value of only one potentiometer in binary and ASCII. The code below is for binary (Serial.write) data, for ASCII we would use Serial.print instead:

Screen Shot 2015-10-12 at 14.04.27

Then I’m sending data in different formats:

Screen Shot 2015-10-12 at 14.04.09

Then try two different formatting styles: punctuation and “handshaking”. Punctuation:

Screen Shot 2015-10-12 at 14.18.25 Screen Shot 2015-10-12 at 14.18.46

“Handshaking”:

Screen Shot 2015-10-12 at 14.25.22 Screen Shot 2015-10-12 at 14.25.31

Questions from the lab:

  1. Sending data in different formats: when do I know which one I need?
  2. Reading several sensors: what does the 3rd column stands for as we’re reading only two analog sensors?
  3. Reading 2 analog 1 digital sensor: can it all be put in the loop and not separately?
  4. More general question: what’s most important to remember from this? In other words: could we go through some practical examples when this would become handy?

Leave a Reply

Your email address will not be published. Required fields are marked *