Arduino Week 1 Blog Post

 This week I took a dive into beginner programming using the Arduino open-source electronics platform.

My challenge was to build a circuit on a breadboard and program a code to make an LED light blink.  Simple enough for a beginning project I thought, so although I had some bumps along the way, I extended it to include a second LED light that remained constant while the first blinked.


Below is a screenshot of my code. The blinking led light was labeled "13".  "Void setup" begins a program whereas "void loop" has the program run until the power is disconnected.  "Output" is the flow of electricity (the source being your computer) into the led light.  I don't know quite why "led" must go before output and not the other way around.  I also don't know if it is important to capitalize words such as "OUTPUT, HIGH or LOW" as playing around with capitalization didn't seem to make a difference. "HIGH" stands for "on" and "LOW" represents "off" which allowed for the program to cause the light to blink "on" and "off."  "Delay 500" represents the delay between the "HIGH/LOW" or "on/off" functions.  I switched between making the delay 500, 1000, and 2000.  The greater the number the longer the delay, and therefore a higher delay, such as 2000, causes a slower blinking of the light.  A shorter or lower number (500) on the delay causes the light to blink faster (which is what I ended up liking best and ending my code on.


Below is a photo of my circuit on the breadboard.  This was ironically more difficult to get right.  I needed connecting wires as well as a resistor (to "resist" the amount of power going through and keep my led from burning out), and an led light.  I thought I was successful with my first circuit (picture one) until I became concerned with the brightness of my light and realized my resistor was not a part of the circuit so my light was receiving unresisted power.  I fixed this with the second circuit (picture two) using another wire to connect the cathode (short wire of the led back to the ground).


                                                            picture 1 (light is too bright, resistor is not working)

                                                    picture 2 (resistor working)

Here is a rough sketch/diagram I made of my two circuits that I drew in my design journal.....


   



Below is a video I made of my circuit explaining how the program corresponds to the circuit in the breadboard.  In the video I added an extension to the code by adding a "constant" led light which I titled "one."  I kept this constant on "high" (on) since I did not intend the second light to blink.  I added a wire to the short leg of each led and connected the wire to the negative "ground" strip on the breadboard.  The black wire fed the circuit power of both led lights back to the ground connection in the source.  So the complete circuit is as follows.....
The red wire feeds the power source (the computer and it's battery) into the positive "plus" strip, then to the resistor (to decrease the power and spare the bulb from burning out), then to the led light that blinks, then to the extra orange wire that is connected to the negative (ground) strip, then to the black wire and the back to the source.  Meanwhile I created a second circuit with another wire going from the source "1" via a new wire into the positive side, then through another resistor, then to the second led light (labeled "1" in the code) which was programmed with a high (on) but no low (off), then to a new wire, back to the negative ground, and finally feeding back to the black wire at the same time as the blinking light's circuit, and back to the origin.


I was surprised at what a challenge building the circuit itself was, compared to the actual coding (proving you need practical application knowledge as well as theoretical).  I did not initially include the extra wire connecting back to ground, causing my circuit to not be complete and my light not to blink.  Once I remedied this problem, I got my light to blink my joy was shortlived, as I realized my light was way too bright and my resistor, while plugged in, was not part of the circuit.  After remedying that problem, I got the blinking light to happily work, encouraging me to add the extension.  My insecurity now that there is still an error, stems from the fact that I needed two separate wires connected to source in "port 1" and "port 13" respectively and did not make a complete circuit with both bulbs stemming from just one port (but I will keep working on it).  The code in the computer I found relatively easy to understand although I am unclear what exactly the "void" function is for other than to represent that there is nothing before and after the program and that everything else but the program itself is "void?"  One misconception I may have is my assumption that the "//" symbol turns a line of code into a comment so adding it to a code basically deletes that line of code when you run the program but I could be wrong. 

Another crazy thing was that no matter how many times I changed the code, the breadboard kept running my original code, and even kept running it when I connected it to a computer that did not have Arduino on it!  I shut everything down and rewrote the whole code (luckily I had taken a picture of my original code), but I still don't know how the whole code became so imprinted on the breadboard that it kept running even with a power source that was not connected to Arduino.




Although there will be a steep learning curve for myself and later projects, because I feel I have just scratched the surface, I am excited and motivated for my next foray into the world of coding!

Comments

Popular posts from this blog

Week 5 Piezzo Buzzer Arduino Project