Monday, January 20, 2020

Photocell to control multiple LEDs

Whoa! This project was a lot of things not working! Originally I wanted to try out the force-sensing resistor (FSR) as I was not able to get it to work properly in the class. So I looked up a few tutorials but the best one that I could find was from this site:
At the bottom are the instructions I followed for this project. First I used the code provided to us by Bryan, readVariableResistor, to get the raw data in the Serial Monitor but no matter what I was not able to get a reading higher than 0 when pressing down on the FSR. To test that I circuit was set up properly I switched the FSR with a photocell and even in my low light set up was able to get a reading between 0-55. This is probably my favorite part of using a sensor and the Arduino, you can make a photocell trigger your project no matter the lighting conditions, so no matter where you need to set up one's project it will always work!
After playing around a bit I still was not able to get the FSR to read so I decided to stay with the photocell since I knew that was working.

I decided to still use the code provided by the makerguides website as it was working well with the new reading inputs but I did want to change it a bit. One thing I wanted to add is the consolidation of the pinModes as we learned to do in class. Changing the values of the numbers to 3 and 7 as those where the pins that I was using.



But the verification did not like that one bit and I would get the error message:



After changing the code by to the original bulky pinMode setup. I also took out most of the defined pins, except for A0, as I feel like that is redundant since they are also defined in void setup. This left me with the code looking like this:



Fairly similar to the original but I could not figure out a better way to condense it.

Now to the next issue! I could not get the LED on pinMode 3 to trigger at all, as you can see in the photo and video. It must be something in the code that I am not seeing because I took out and replaced all the components on the breadboard twice to no avail!

 The final set up
A better few of the Arduino and the wire set up


All in all, even though the FSR did not work, and I would like to understand why at the moment I prefer using photocells with the Arduino to trigger events because with long enough wires they are so easy to hide from a viewer.

No comments:

Post a Comment