Jed Segovia, Week 5: Ice Cream Sandwich Sensor Homework

My code for this project.

I wanted to make an easy sensor so I could focus my energy on the Arduino code.

I used the ice cream sandwich swatch example shared by Cat Schmitz. I cut a circle of foam, cut a hole in the middle, and sandwiched it between two velostat sheets. Now I needed lobster clips to complete the circuit.

When I got that working I tried using the sensor instead of a regular button in the typical Arduino Button sketch. I replaced the button with two lead wires, and lobster clipped them with my button. It didn’t work. I was dismayed because it looked like my sensor button wouldn’t work. I also realized the Arduino cable was broken, and not detecting my port. Another setback. I left to buy two Arduino USB cables at Tinkersphere in 5th Street, and I spent an hour doing that.

It wasn’t until I reviewed the previous week’s slides did I realize that there was a sketch called “ReadingSensorValues.” I couldn’t find it in the Arduino examples, and was at a loss, until my classmate Audrey pointed out there was a link to our instructor’s Github right under the slideshow. Thankfully Audrey pointed it out. I ran the sensor homework and voila, I got the sensor to produce a range of brightness in my LED.

Using this template, I would now scale it up to three LEDs. First, I scaled it to two.

Scaling it up to two, I wanted to activate the first LED immediately, and activate the second LED only after pressing down the button for a certain time.

I struggled to use an If/Then code, so I went with While, which is certainly interesting. My first successful attempt was turning on the white LED right away, and when the sensor is pressed, the blue LED lights up. When the blue LED’s value goes beyond 150, the white LED turns off.

I finally got three LEDs to work with if-then statements. The circuit is based on how much pressure is delivered on my button. The blue LED lights up first. When the blue LED value goes beyond 110, the white LED lights up. As long as I am pressing hard on the sensor, the values of both the blue and white LEDs go up. When the white LED value goes beyond 140, the yellow LED lights up.

Lovely. Seeing the LEDs light up with a range of brightness is exciting. Plenty of potential applications to many projects.

Now to see if I can synthesize this into my Internet of Things homework.

Leave a Reply

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