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.

Monday, January 13, 2020

LEDs - let's flash some lights!

I used six LEDs for this project, with the Arduino I created ~30-second sequence. I used the 5V output powering the Arduino with my laptop. Using the pins 5-10 to power the breadboard and the individual lights. For reference, all warm-colored cables are positively charged and cool colors are negatively charged.

My circuit board
closes ups of the wiring.

This part was pretty straight forward from our class practice. Powering each LED with its own pin that then has its own resistor. To make a somewhat symmetrical layout I powered both sides of the breadboard with the red and black jumpers as seen in the top image. 

The code was a bit trickier, not in the actual turning on and off (HIGH/LOW) of the LEDs but the code itself is long and clumsy looking. There are probably better ways to turn off and on full sections of LEDs all at once as I have in the code posted below but in better shorthand, maybe an array?

 Although the code is bulky, I am pretty happy with how the sequence itself turned out.