Sunday, November 25, 2018

Success or Failure Sometimes Its Like the Roll of the Dice!!

This week our assignment was to create our own code to make 7 LED simulate the different sides of a dice using a push button to simulate the rolling of the dice.  This just about blew my mind.  I watched Dr. B's video many times and took notes.  I watched the information about the way to use the functions in my code.  I looked through my Guide book for my Arduino.   The same question kept pop up through my brain and panic was setting in. "Where am I going to start".

Well I tried to brake down the assignment but I was still stumped.  Instead panicking I decided to go to the all mighty internet for some help with this as well.  I found a video  (www.pimylifeup.com)  of this challenge with schematics and coding along with the explanation of how to create the boards. I was relieved to have something to use as a tutorial for this project.




On the breadboard I set up the LED's so each LED was located on its own bus.  I placed a resister next to each LED to regulate the current to the LED.  I placed a red jumper wire to the 5v then over to the first positive slot on the breadboard. Then I ran a black jumper wire to the ground under the 5v then over to the first negative  slot on the breadboard. I placed my 7 LED in the same way Dr. B diagrammed in the video onto the breadboard.  Now to place wires from the Arduino to each LED.  I placed a wire to the 12 pin over to the number 7 LED place it next to the LED on the LED's left.  I also placed a resistor by the LED.  I continued to do this with each LED, connecting a wire from pin 11 to LED number 6 pin, wired to the  10 pin   to LED number 5, wired 9 pin to LED number 1, wired the 8 pin to LED number 2, wired to 7 pin to LED number 3 and then  LED number 4 was in the middle is located so it pulls power from the 9 pin as it is positioned so it sets horizontally from the jumper wire.  I placed the push button so it straddles the 2 sections of the breadboard.  I placed a shorter black wire next to the button and ran it to the 1 pin.  I placed a short orange wire above the black wire on the breadboard across to the Arduino pin 1.   I used a 10K resistor next to the button on the positive side.

  At this point I created a diagram of the 7 spots using the correlating number on the Arduino board that the different wires were connect to.
Below is that diagram and also how I have my board wired.



Now it is time to code.  I used the basic code from the example online but soon realized I had to modify it to make this project work.  I spent a total of 8 hours trying to get this to work.  One of the main problems I had was getting the code approved to upload to my computer..  It kept saying the word "all" and the number 6 were not declared in this scope.  I tried to fix this by taking out all of the  "clear all".  It  finally was approved to upload but now I had all of the buttons on.  NOT
WHAT I WANTED.  Back to the drawing board!!!!





When it said the number 6 was not declared in the scope I was differently confused. The number 6 along with the numbers 1-7 were declared at the beginning of the code.  After trying to change the wording, deleting and recopying the original code again I was still out of luck.

Finally I changed Clear all and manually put in All LED to Low delay (4000) so the lights would stay lite for 4 seconds, so random numbers would stay lit for 4 seconds as it randomly rotated on its own.  I was getting closer but when I pushed the button the lights went out instead of changing now I had to figure out how I could revise the action that was happening so the lights changed when I physical pushed the black button.  I was stumped!  Finally, I tried to change the word High to Low on the line of code that said, if (digitalRead (button) == Low && state ==0); and just like that it FINALLY WORKED!!!!! After hours of frustration and feelings of self doubt I was jumping up and down at 1 a.m. with excitement.























                                                        Here is my working project!!!

 The final assignment was to roll the dice 100 times and create a spreadsheet of the results.  Those results are show below.


 Well I hope all of you had a Great Thanksgiving and hopefully next weeks project will go smoother then this week's project.

Sunday, November 18, 2018

Week 3 It's getting deeper in Here!!



This week I worked on the 3rd circuit  in our starter kit guide.  I constructed the Arduino and Breadboard as instructed using 1 RGB LED, 3 330Q Resistors,  and 6 jumper wires.
It is so fun to build the circuit now as I feel I am getting more confident as I progress.  The code was very long this week that was written on the Arduino software.  As I typed the code, leaving out the instructional information I spent several hours getting it right.  I kept loosing my place as I typed and either skipping a section of code or doubling it.  Once I had the code checked and it was finally okay to download I was relieved.  My persistence paid off as the RGB LED blinked in the three colors as directed.



Here is my board and the code I followed.


Here is part of the code that gave me a hard time.  It was too long to screen shot all at one time.






Once I was successful by following the directions step by step I read what was asked for in the challenge.  It wanted me to incorporate 2 or 3 codes together to get a new result.   I worked for another 3 and 1/2 hours trying to accomplish something but after countless attempts at adding a yellow LED to the board and additional jumper wires then coding it to flash along with the RGB LED with no success by adding the 2 codes together. However, I combined the code from the first week adding a 10th of a delay, and removed the extra LED and jumper wires and I got the RGB LED to blink faster but that was my only success with this step.   I am sure many of you did this with no problem and I look forward to reviewing your blogs again to get more insight on what you did differently than me to be successful with this challenge.



Here is my small success by just adding delays to the code I wrote for this week.
     

Sunday, November 11, 2018

Week 2 Let the Learning Continue!!!

  


Nov. 7, 2018

Today is the day I start playing with my Arduino and work on Circuit #2.  The new vocabulary is Potentiometer or a variable resistor.  This resistor when connected with 5 volts across its tow outer pins, the middle pin outputs a voltage  between 0 and 5, depending on the position of the knob on the potentiometer.  This will control the brightness of the LED.

For this circuit  I needed 1 potentiometer, 1 LED, 1 330 resistor, and 6 wires.  Before I connected the Arduino to the computer I built the circuit according to the diagraph on page 24.  I connected my red wire to the 5v on the Arduino and then to the breadboard on the right vertical side to the bottom positive bus. Next using my black wire I connected it to the GND then to the breadboard's neg bus.
Next I used the green wire from the A0 to e7 on the breadboard.  I attached a red wire to 13 on the Arduino to j20 on the breadboard.  Next was the resistor from j21 to neg. bus straight across. I used a short orange wire from e8 to positive bus placement. My blue wire went from e6 to a neg. bus on the breadboard, finally I put the potentiometer to a6,a7,a8.  Now it is time to plug my Arduino to my computer.




Now comes the fun part.  I have learned one little mistake and the code will not work.  I was careful to make a clean copy of the code so I would have it before I started playing with it.  Below is the code I used and my LED was able to go high and low as the potentiometer knob is turned.
int sensorPin = 0;
int ledPin = 13;
void setup()
{
  pinMode(ledPin, OUTPUT);
}
                                                                       
void look()
{
  int sensorValue;
  sensorValue = analogRead(sensorPin);
    digitalWrite(ledPin, HIGH);                                               
  delay(sensorValue);
  digitalWrite(ledPin, LOW);
  delay(sensorValue);
}

 Circuit and Code Play


1.  See what happens if you use two digital pins rather than one digital and one analog pin.
 I moved the green wire from the analog pin from A0 to digital 12- the LED blinks at a stead rate the potentiometer makes no change in duration and frequency of blinking.

2.  See what happens if you use two analog pins rather than one digital and one analog pin.
      I put the green wire back to A0 then unplugged from digital 13 then put into Analog 1.  No signal was coming from A1 to J20.  LED does not blink at all.

3.  What happens if you replace analog Write  with digital Write and vice versa?
I changed all digital Writes to analog Writes  then I uploaded new code to the board.  LED flashed fast then went off.  Where as distal Write on the original code told it to turn the light off and on. 

Extension Challenge

1.  Can you control 2 lights with the same brightness or same blink rate?
   I added another red wire from 12 to 22 leaving 13 to 20.  I put on the second LED.  I was able to get both lights to blink but did not get the control that was asked for.  I changed the code and inverted the High and Low which did not work.  I was stumped.  Looking forward to reading others blog to see where I went wrong.  
  
Here is a video of the 2 LED blinking.


Sunday, November 4, 2018

Steps to success and sometimes failure.

I start my adventure into technology after I download the Arduino IDE program, get my blog and you tube accounts set up.  I think I am ready to dive in !!!!

Oct.31, 2018 I open up my blue box and find all sorts of wires, boards, resisters, and pins.  I must admit I am feeling a little overwhelmed.  As I read the starter kit guide I put the boards on the plate only to be told by my son I have them upside down.  After I fix this I am unsure if I need to put in the code given to us first or put the things needed on the board.  I get stuck because I am not sure just what to write into the computer.  Do I put in just the symbols or everything word for word.

Nov. 2, 2018  I sent out a SOS to my classmates asking how the code needed to written.  Before I got a responses my oldest son offered to set with me and help me through the process so I could have a foundation of procedures as I work through this process.  He told me to connect all things first as illustrated in the guide book.  As I do so he explained about the positive and negative sides and how the circuit follows to make things possible.  Once I had all components installed I hooked the board to the computer and the light was on.  Now to make it blink.  I decided to type the code in as written with the directions included and shazam it worked, my light was blinking as directed.  My First Success!!!!!!




Now I was feeling more confident.  I started to play with my board.  My first attempt was to reverse the wiring and nothing happened the transistor did not light up. Next, I changed the digital bus from the #13 directly to the positive to the breadboard.  It made a simple circuit and the light did not blink but stayed on solidly.  Next, I tried removing the positive lead from the breadboard and nothing happened because the circuit is completed through the #13 digital pen using the green wire. Then I tried moving the wire from #13 to #12 on the Arduino and I found I needed to change pin 13 and intled=13 both to 12 instead of 13 in order for it to work on the 12.
Finally I tried changing the code from (1000) to (2000) and saw that the light blinked much slow.  When I changed it to (50) the bulb blinked much faster.