[PCOMP] Input and Output

This lab, I worked with the Arduino and digital input/output and analog input. We started using the Arduino IDE for the first time, starting with the simplest commands, such as making the LED shine and blink. I used the basic blink code to make it so that when the switch is activated, the LED turns on. It worked for the LED, but not the tilt switch component given during class. Chris and I met up to chat about the wiring outside of class, but we weren’t sure why the tilt switch wasn’t working (pictured below on the left).

Next, I wired up to LED’s so that one LED lights up when the button is pressed, and the other one lights up when the button isn’t pressed. I used the code on the right. I thinking figuring out the code is the part I enjoy most about physical computing.

I then attempted to wire up a potentiometer to the LED using analog input into the Arduino to read and interpret the pot data for the LED. I was surprised to see the LED be able to respond to the subtle changes of the knob. If I twisted the switch towards the left (power side), it became brighter and had lower resistance. If I twisted the switch towards the right (ground side), it became dimmer and had higher resistance.

I soldered wires for the first time. I put off learning how to solder for a while, but it was more fun than I expected. It makes me intrigued to do more metalworking (perhaps in the context of jewelry making) in the future.

I soldered wires to try to get my speaker to work. I used the same code as the pot / LED exercise, but changed the terminology from brightness to frequency to avoid any potential confusion. It was cool to hear the sound come out and change with every knob turn. It was a less seamless gradation between the frequencies for the speaker than the gradation for the LED brightness, which was very seamless.

Next, I wired up two FSR’s and set them to send digital output to the LED’s. It made sense that the brightness needed to mapped to a different range (from whatever the input range was and to whatever the output range needed to be. I think currently, it is not too clear to me when I should use digitalRead vs. analogRead and digitalWrite vs. analogWrite.

Next, I attempted to find the sensorValue range for the photoresistor, but the values kept jumping all over the place. I tried a couple methods, first by setting a threshold and second by calculating the average of the readings (with Kaye’s help). However, there seemed to be too much noise and not much of a difference between when I covered the photoresistor with my hand (mimicking “darkness”).

Switching back to the button, everything read smoothly again. This part was pretty fun and I’m already seeing all the possibilities for making toys, keyboards, games using physical switches to map data into art pieces I want to make. It could even be as simple as a cookie clicker. Perhaps I will make a cookie clicker game with a button in the shape of a cookie.

I felt like I was talking to my good friend the computer, and the computer was talking back to me.

The analog input worked well for the FSR as well. I changed up the Serial print text format so that it would be easier for myself to read. Currently, I only vaguely understand how the math works (with threshold, noise, and peakValue). I’m looking forward to understanding it better conceptually tomorrow in class.