This week in
my ETEC 568 class – Makerspaces I was challenged to build a circuit where I
could control an LED with a potentiometer. The first thing I did was go to my
book to look up what a potentiometer was so I knew what it was supposed to do. I
learned that a potentiometer is a resistor with a knob that will control the
voltage going to the LED causing it to get brighter or dimmer or to blink
faster or slower depending on what it was coded to do. Now that I understood what was going to
happen, I set out to build the circuit.
Once I had all the materials, I followed the directions from the
sparkfun Reading a Potentiometer and things were going well until I got the
spark fun potentiometer (or pot) and the one in the directions had all the pins
in a row and mine had two pins on one side and the third on the other. This threw me for a loop and I spent quite a
bit of time trying to find the answer to how it was supposed to go in the board
compared to the one in the directions.
Needless to say, I never really found that answer so I put the pot in
a7, c7, and b11 in my breadboard because this was the way that it would sit
flush with the breadboard. I got all the
other wires and pieces in place, then added the code to the Arduino IDE and
sent it to my UNO. Well, guess what
happened, I got an error message saying that it didn’t recognize/find the
board. I closed the program and tried
again and again. I couldn’t figure out
what was going on because the program verified the code and I didn’t get an
error until I tried to send it to the UNO.
I should have remembered from one of the videos I watched last week that
I needed to hear that noise saying the computer recognizes the board. I didn’t hear the noise but I didn’t realize
that until a few hours later. I asked my
husband if he had another USB A/B cord, to which he thought he did but
didn’t. Thankfully I was already
searching Amazon for a new one when it showed that it was the code for Cannon
printers and that is the printer we have. I took that cord and tried it and
still go nothing. So, my husband said
either the board is bad or the port is bad or the USB cord is bad. I was hoping
it was just the cord, so I ordered one but didn’t want to just sit and
wait. I remembered reading in my book
about a 9V battery cord, so I got that out with a 9V and put the red into pin
13 and the black into the GND, and guess what it lit up so I knew that it
wasn’t the board. This is when I with
the help of my husband realized that it had something to do with the ground
wire because when I unplugged it the LED would blink. So, we unplugged all the wires that had to do
with the pot and the LED was still blinking. I was glad that the board was bad
and I decided I needed to unplug everything and start over with the build. This
time I decided to turn the pot so that it didn’t go all the way into the
breadboard putting one leg at a6, one at a8, and the last at e7. I now know thanks to some wonderful
classmates that the way I had it the first time had both the positive and
negative in the same row which was causing it to short out since they can’t be
in the same row.
1st set up attempt.
Top picture: 2nd setup, 2nd setup diagram –
working circuit
Below is the cleaned-up code I used to make the LED blink and control how fast or slow it was blinking.
Working pot circuit.
After getting the initial challenge to work I went to play with the circuit and code play for the week. First, I tried to see if I could control using two digital pins instead of one digital and one analog. So, I changed A0 to pin 8 both on the board and in the code and when I did this, I got a blinking LED still but I wasn’t able to control it with the pot. Then I thought I wonder if in the code I need to change pin 8 to be input rather than an output if that would allow me to control it. Well, it didn’t, so I wasn’t able to control the blinking of the LED when I used two digital pins. As I thought about this setup, I wondered if analogRead needed to be changed to digitalRead to make it work. I tried it and I got a LED that stayed on but I wasn’t able to control it with the pot. The same thing happened when I tried to use two analog pins instead of one digital and one analog. I moved pin 13 to A1 on the board and changed it in the code. When I did this the LED didn’t light up, so I couldn’t control the LED with the pot. While I was in the second set up, I wondered if I needed to change digitalWrite to analogWrite in the code to make it work, so I did that but still got nothing.
Now, I moved on to the Extension Challenge part of the week. The first challenge was to control 2 LEDs with the same brightness or same blink rate. At first, I had a red and blue LED and I was able to control the two lights with the same blink rate but not the same brightness since they were different color LEDs. For this set up I had the LEDs in series. So, I decided to see if changing to two of the same color (2 blue LEDs) would allow me to be able first, to control the same brightness and blink rate at the same time, again this was in series. When I did this, I was able to control both LEDs with the same rate of blink and brightness. Below is a picture of the LEDs in a series
This is when I realized that I probably needed to put each LED on its own pin, so I went back to a blue and red LED and left the blue where it was in i20, i21 and put the red in h26 and h27, the jumper wire from i26 to PIN 8, and the resistor in g22 and negative. I then went and added the second LED to the code and when I did this, I was able to control both LEDs with the same rate and brightness.
Below is a picture, video, and code for this.
The second
part of the Extension Challenge was to see if I could control two LEDs with one
potentiometer but have either one gotten dim while the other got brighter or one
blink fast while the other blinked slow.
I tried switching the HIGH and LOW for the LEDs in the code to be
opposite of each other and this just caused them to blink opposite of each
other. Then I tried adding a
delayTime=100 into the code and put that after the first LED in the code to see
if this would cause the blue LED to blink faster than the red.
This too
just caused them to blink opposite of each other. So, after a few hours of messing with it and
looking for a solution I gave up and decided that was enough.
Here are the
codes I used to try and get the second extension challenge to work.
First one below:
This build
taught me again that making sure the positive and negative aren’t in the same
row causing a short is important and will cause lots less frustration if I make
sure to not do that anymore. It was also
again clear that the coding in the program has to be right in order for me to
get the outcome I want. While I wasn’t
successful in getting the second part of the extension challenge to work I know
there is a way and it is probably simple but since I am new to this whole thing
and don’t know all the other possible codes I could use and didn’t find one
that would allow it to work I still learned some important things. I can find potentiometers in the volume knobs
of televisions, or the wall knob for a ceiling fan that allows the fan to speed
up or slow down and even to turn off and on. I would assume they are also used
in the big flashing arrows on roads that tell you to move over to another land
because of construction. I look forward
to seeing videos or explanations next week of this week and seeing where I was
off. I also realized that I have
classmates that are more creative than I am when it comes to the way they share
their information on their blogs. This
is again showing me that while I thought I knew a lot about technology and
technology things that I really only know about the things I use all the time
and not about all the programs, apps, and things out there.






