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:
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:
Then I’m sending data in different formats:
Then try two different formatting styles: punctuation and “handshaking”. Punctuation:
Questions from the lab:
- Sending data in different formats: when do I know which one I need?
- Reading several sensors: what does the 3rd column stands for as we’re reading only two analog sensors?
- Reading 2 analog 1 digital sensor: can it all be put in the loop and not separately?
- 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?