Exercise 4 - Serial Communication

Part 1

The first part of the exercise was fairly easy to complete as I've been using the serial window as a console for debugging sensor values for the past several exercises. I set up the button example with a photo sensor and logged both values to the console.

Part 2

Part 2 was a little more difficult for me and I used several tutorials to help me understand the communication aspects of it. (1) (2) (3) The sketch I ended up creating works by having three buttons in processing that are red/on when the mouse is over them and black/off when the mouse is not. Each button corresponds to an LED on the breadboard. This section involved a lot of repeated code for me so next time I am going to try and create a reuseable button or element to make it faster and easier to iterate on.

Part 3

Part 3 was a solid extension of the concepts from part 2. I used 2 potentiometers and a light sensor to control this sketch which then sent the instructions back to the Arduino. The first potentiometer controls the X value of the box highlighted in red and the second controls the Y of the black box. The boxes kept their mouse over to highlight red behavior from the last part. The light sensor controlled the background on a scale of white to black, reusing some of my value mapping code from the first project to "zero" itself with the light value present when it turns on. Then after receiving the values from the sensors it sends back the data for the arduino to turn on whatever LED is bound to the button currently highlighted in red, and using a PWM only turn it on as bright as the color value of the background grey. This means the darker the light sensor the brighter the LED.

Part 4/5

Still in progress.

Comments