Photo

Photo

Thursday, March 3, 2016

Arduino Introduction Part 2

During Tuesday's class, we continued to work on Arduinos. 

The first thing Jiaming and I had to do was to alter the code of our LED pattern that was created without the use of delays. We originally created it with multiple if/else statements under one umbrella if/else statement, but Amy wanted us to make it so that the lights blinked independently of one another – controlled by different time commands.

This assignment took us the longest out of all the Arduino programs we've been working on. The crux of the problem was to realize that we would need three separate time keeping commands – one for each LED. It's sort of like having three different stopwatches going at the same time. Each stopwatch works independently from one other, so that each LED can work independently from one another.








For our next assignment, we learned about photocells. Photocells are these pretty interesting resistors that adjust their resistance based on the amount of light hitting its sensor. In order to use photocells in our circuit, we first need to get an idea of the numerical values they relayed based on varying amounts of light. Using a code that included a few print lines and the help of the Serial Monitor tool, we were able to figure out the values that corresponded to: very bright (flashlight shined on photocell), bright(normal classroom white light), dim(hovering hand above photocell), and dark(covering the photocell completely). We did our calibrations with two different resistors in the circuit in series with the photocell, the 1k and the 10 k.

 
























Once we calibrated values for the photocell, we had to create a LED pattern with it. We were given a lot of leeway in this assignment, since we were given the choice of deciding what we wanted our photo cell to control. Jiaming and I decided to have the light level of the LED determine a specific light pattern. If the photocell has a flashlight shining on it, then all three LEDs will turn on then off. If the photocell is in normal light, then there will be a LED pattern in which the LEDs will cycle through a pattern of having only two LEDs on at a time. If the photocell is under dim lighting, the LEDs will turn on and then off sequentially. If the photocell is in dark lighting, then the LEDs will cycle through a pattern of the 1st and 3rd turning on and then off while the 2nd turns on.

 
 
 



















For the next assignment, we learned how to use a button to turn on a LED. When we pushed the button, it would complete the circuit and power kPinLed, which the LED was connected to.

















The next thing we needed to do was to learn about servos. To get started we downloaded the templates of sweep and knob to get started. After we got an understanding of what the code did, we then had to alter the knob code so that it would only rotate the servo from 60 to 120 degrees.



















Reflections:

Today's assignments were devoted mainly to learning about the various things we can power/use with the Arduino.  We learned how to use photocells, push buttons, and servos. I actually really like working with the photosensor – although, I do have to mention that the first time around, we accidentally plugged the photosensor in backwards, so the numbers were flipped. Regardless, I'm excited for when we get to use the photosensor in a project. The button assignment was pretty straightforward and I'm pretty curious as to how we'll use the servo in a project.

I'm still adjusting to the coding terminology in Arduino, but it's not too much of a problem. The hardest part is definitely figuring out how the stuff on the breadboard connects to what's written in the program. The setup portion of the code isn't difficult now because it's just given to us, but I imagine that if I had to start from a blank code, I would definitely be very confused. I'm at the point in which I can understand what's happening in the code, but would struggle to create my own setup code.

All in all, I'm having fun exploring the use of Arduinos and am looking forward to learning more about its applications!


2 comments:

  1. Amazing job with the coding and with explaining what everything that the arduino, breadboard, and pieces have to do.

    ReplyDelete
  2. I like your LED pattern with the photosensor! Very creative and fun to watch.

    ReplyDelete