Saturday, October 31, 2020

Challenge Build One - The Blinking LED

 

For this project, the goal was to get the LED to light up by using pin 13 as the source for the voltage to flow through.  I got the Arduino Starter kit that had the Arduino UNO R3 and I will have to say when I opened the box I was overwhelmed.  Then when I read the directions for the challenge and started to follow the directions in the book for The Blinking LED, well my book didn’t have directions so I used the link that my professor, Dr. B, sent and then got started even though I still wasn’t sure what I was supposed to be doing. I started by putting the wires into place on my UNO board and breadboard.  Then I needed to add the code to the Arduino program so that the computer could send the code to the Arduino board.  So, I typed in the code just as it was on the assignment post and then I hit the checkmark (verify button) and guess what I got an error message.  At first, I couldn’t figure out what was wrong because it was typed just like on the assignment but when I got to the end of the code from the assignment, I realized that there was some extra stuff at the bottom of the code in the Arduino program.  The extra stuff was what is set to be there when you open a new program and I realized that I needed to delete that. (see below)

Once the extra stuff was deleted and I verified the code again I didn’t get an error message.  So, now it was time to send the code to the board.  I sent the code by clicking the right arrow and nothing happened.  I went back and was looking at the circuit to see why it wasn’t working and was comparing it to the picture of the circuit in the link I was using.  That is when I realized that the black (-) wire wasn’t on the same side of the breadboard as the red (+) wire.  So, I moved it to the same side and then the code worked causing the blue LED I put in to light up and start blinking.  I couldn’t believe I got it to work. 

Here is the code that I used to get the Blinking LED to work.


Here is a picture of my circuit with both the Arduino and Breadboard when it wasn’t working, as well as a picture of my diagram from my journal.


 


Now here is a picture of my circuit with both the Arduino and Breadboard working, as well as a picture of my diagram from my journal.


Now I am adding the video where I realize that I need to move the negative wire to the same side of the breadboard as the positive wire. 


 

Next, is a video where I explain or at least attempt to explain what is happening in the circuit.  

 


After getting the initial circuit to work I then moved on to the Circuit Play.

1.     What happens if you turn the LED around (reverse the wiring)?

When I did this the LED stopped blinking.

2.      What happens if you remove the positive lead from the breadboard?  Does the circuit still work?

I thought that if I removed the positive wire that the light would stop, and I was right.  The circuit doesn’t still work.

3.      What happens if you place the resistor to the positive side of the LED and simply used a wire to run back from the LED to the ground?

I wasn’t sure what would happen if I moved the resistor to the positive side of the LED, so when I did, I got a shock when the LED became much brighter.

4.     What happens if you move the wire from port 13 to port 12 on the Arduino, what do you need to change in the code?

When I moved the wire from port 13 to port 12 it caused the LED to not turn on or blink.

After the circuit play, I moved on to the Code Play.

1.     If you moved the wire from port 13 to port 12 on the Arduino, what do you need to change in the code?

Since I changed the port, I know that I need to change it in the code too.  So, I went and changed the code and when I sent it to the Arduino board it didn’t work and I got an error code. So, I went back and looked again at the code to realize that there were two places that I needed to change 13 to 12 and I only changed one the first time. After changing both of them it worked and the LED was blinking again. 

2.     What happens if you change the two delay code lines from delay (1000) to delay (2000)? Take out a stopwatch or time and time the rate of linking for each settings.  How many times does the LED blink in a minute for each of these settings?   What have you learned about the value that is placed between the parenthesis after delay()?  What value (parameter) would you place in the delay() if you wanted the LED to blink at a rate of once every 3 seconds?  How about every half second?

When I changed the delay from (1000) to (2000) it caused it to blink for two seconds on and two seconds off, which is a slower blink than at (1000).  For (1000) it blinks 30 times in 1 minute and for (2000) it blinks 15 times in one minute.  The value place in parenthesis after delay is the time per high or low (blink) in milliseconds, meaning how long it is on and how long it is off.  If I wanted to make it blink once every three seconds I would but (3000) and that would make it blink slower and then if I wanted it to blink every half a second, I would put (500) making it blink faster.

3.     What happens if you place // before the words void setup()?

When I did this I got an error message saying expected constructor, destructor, or type conversion before “{“ token – pinMode(led,OUTPUT).

4.     What happens if you place // before the words void loop()?

I got the same error message I got for number 3.

5.     What happens if you remove the last curly brace “}” in the program?

When I did this, I got an error message that said expected “}” at end of output.  This tells me that it has to be there or the program won’t work and doesn’t know that it is the end.

6.     What happens if you place a // before pinMode(13,HIGH) in the setup()?

Well I don’t have pinMode(13,HIGH) but I put // before pinMode(led,OUTPUT) which causes pinMode to go from orange to

black and I have come to the realization that it needs to be orange.  I didn’t get an error message though but the LED was blinking dimmer.

7.     What happens if you changed HIGH to high on the pinMode(13,HIGH) line?

When I changed HIGH to high it went from blue to black, which again I have realized color is good in programming.  My HIGH was in digitalWrite(led, HIGH) and when changed to high I got an error message saying ‘high’ was not declared in this scope.

8.     What happens if you change the word pinMode to pinmode in pinMode(13, HIGH)?

Again, I don’t have pinMode(13, HIGH) but when I changed pinMode to pinmode in pinMode(led, OUTPUT) it caused the words pinmode to go black from orange and I got an error message saying ‘pinmode’ was not declared in this scope.

 

I had some extra time so I tried some of the Extension Challenge.

First, I added a LED by putting a green LED into D7 (+) and D8 (-), a resistor at C8 and into negative, and then a green jumper wire from pin 12 to E7.  I then went to adjust the code since I added to the circuit, I need to add it to the code for the program or the program doesn’t know anything needs to be done.  I added int led2=12; below where int led=13; was.  Then I added //pinMode(led2, OUTPUT); below //pinMode(led, OUTPUT);.  Last, I added digitalWrite(led2, HIGH); and digitalWrite(led2, LOW); before the delay codes.  I clicked the checkmark to verify the code and I didn’t get an error message so I hit the right arrow to send it to the board.  I was disappointed because it didn’t work or at least I thought it didn’t work, only to look closer and realize it did work just but the green LED was much dimmer than the blue so it was hard to see.  So, I changed to two blue LEDs so I can see it better and it worked much better.  These were blinking at the same rate.  Here is a picture of them blinking at the same rate on the left and two LEDs blinking at different rates.  The one at different rates wasn’t blinking like I was hoping but it was blinking at different rates. 

                      

The last challenge I did was to have one LED blink and one LED stay on.  I was able to get this to work.  Here is a picture of that and a picture of the code for it.




This project has taught me that coding in the program and order is super important and that orange and blue colors for certain words are important and a good thing.  I learned that this can be fun but frustrating at the same time.  I might have to do some research or looking for explanations to help but they are out there and can help when my understanding isn’t there, which is going to be the case because this is all like Greek to me.  Also, you can’t misspell anything or leave out any part of the code if you want it to work.  I am sure it will get easier the more I mess with and play with it through this class.  Examples of the Blinking LED circuit that I could find out in the real world would be in the blinking don’t walk for crosswalks, as well as the LED light on a flat-screen TV.

Final Post: Personal Retrospective

  WOW!!   I am not sure where to begin.   When I saw the assignments and things in week 1, I wasn’t sure what I had really gotten myself i...