Physical Computing: Week 2 Labs

In this lab, I explored how to utilize both the digital and analog ports on the Arduino Nano and tried out different sensors.

Screen Shot 2021-09-17 at 7.36.14 PM.png

Error Message

After wiring my breadboard and verifying the code I attempted to test out my first Arduino-powered circuit for this lab but ran into two problems: 1) even though I had updated my Arduino software whenever I opened it still said it was an old version, and 2) one of my USB ports doesn’t work. Once I deleted and re-downloaded the Arduino software and switched USB ports things went pretty smoothly.

Screen Shot 2021-09-19 at 5.02.42 PM.png

/* Q&A in the comments */

Q: What is PWM?

A: Pulse with modulation, PWM, is a technique for getting analog results with digital means.

Q: Why are we dividing by 4 to fit into a byte?

The code above assumed you were using a potentiometer, which always gives the full range of analog input, which is 0 to 1023. Dividing by 4 gives you a range of 0 to 255, which is the full output range of the analogWrite() command.

Screen Shot 2021-09-19 at 5.03.45 PM.png

//Not getting anything on the Serial Monitor

At this point in the lab, my Serial Monitor was not displaying text when the button is pressed. The code was right. The circuit was right. But nothing.

Screen Shot 2021-09-22 at 1.23.48 PM.png

Fixed!

I had my classmate Adnan Aga look at my code and circuit and we could not find anything wrong with it. We thought maybe the button was broken. We flipped the button and moved it to a different row on the breadboard. Wahla! “Button was just pressed” appears on the monitor. I was then successfully able to count the button presses, recognize long and short presses, and read a sensor threshold crossing.

Possible Applications:

In thinking about how to apply these skills outside of the lab I have plans for a greenhouse cabinet that could potentially benefit from dual analog and digital controls. Two of the most essential things for a greenhouse cabinet are lighting and humidity. While the purple hue from grow lights is lovely it’s probably not the best for maintaining my circadian rhythms, so having a mechanism that turns the light off at a certain time and on at a certain time would be useful. This is where a digital control would come in since it operates by letting you switch between two states, 0 or 1, on or off. On the other hand, rather than simply turning the humidifier on/off I’d want it to make adjustments based on the conditions in the cabinet. Using a humidity sensor, I could then set an analog output that adjusts the humidity across a range. Controlling the oscillation of a fan and its force of power could also utilize an analog control.

Source: @APlantProject on Instagram

Source: @APlantProject on Instagram

Previous
Previous

Blog: Synthetic Media

Next
Next

Soundscape