Makerspace Challenge 2: Potentiometer LED
Project : This week you will explore the difference between digital and analog data. You will use a potentiometer which is also known as a variable resistor. By connecting a LED to the center pin, you will be able to control its brightness from fully on to off. Additionally, you will make use of both a digital pin and an analog pin.
The Code: This week I struggled with the code. I got my first error with the code.
Sketch uses 970 bytes (3%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
Failed uploading: no upload port provided. I realized that I had not selected my Arduino Com 3 in the program.
Once I looked at the errors I realized when I was deleting comments, I accidentally deleted part of the code. I had to go to the website and look at the code for analog output in the examples and add it to my code. Once I did this then I realized I did not have my right board selected. I fixed all my errors and it started working! I also changed the delay to 1000 like we did last week because I just thought that is what we had to do. I later realized that it needed to be the speed of the sensorValue in-order to be controlled by the potentiometer.
Arduino board completed: This week seemed a lot easier to complete because I had a basic understanding of everything on the board.
Electronic Diagram.
Video Explanation of setup:
Thinking: I had more confidence in myself when it came to setting up the board. The Guide book has great explanations and easy to follow instructions. I connected each part carefully. Once I had all the parts, then I opened the code. I saved a copy of the code with the documentation then took it out.
Completed board:
Completed Code
Once I fixed all the errors, added back the code for the potentiometer, and made sure I had the right board selected on my program, it started working.
It did take me a little longer this time to understand how all the wires worked and it took me playing with the wires and code to understand all the connections.
Circuit and Code Play
1. See what happens if you use two digital pins rather than on digital and one analog pin. It won’t work because your code is analog read A0, you would have to change the wires to a digital port and you would not get an analog result.
2. See what happens if you use two analog pins rather than one digital and one analog pin. It would not work because again the digital pin would have to be moved to a analog pin and you would have to change the code. I don't think it would work either because to make the led work, it has to be connected to a digital pin.
3. What happens if you replace analogWrite with digitalWrite and vice versa? The circuit would not work because your wire is from an analog pin; When you change Analog read to digital, this made the potentiometer change the the brightness of the light. When I changed the digital write to analog write, this made the light stop working.
Extension Challenge: This week I was pretty confident in myself when we had to add another led. I knew right away again that I had to add another wire to a digital port 12, and then another resistor to the second led and connected to the black wire to ground power. As far as the code goes I knew I had to add another int ledPin2= 12, pinMode (ledPin2, OUTPUT), and also add a digital write ledPin2 HIGH AND LOW. I struggled on the second extended challenge because I could not figure out how to get them to delay at first. I started by putting 9600- sensorValue, but this was not working, and made no change. Then I looked in the book to see what the value was, and changed it to 1000-sensorValue. This still did not work, so I lowered the code to 1050- sensorValue.
1. Can you control 2 lights with the same brightness or same blink rate? You would need to add another wire from the digital port, add another resistor and another led light. Add code for another digital output int ledPin2 = 12; added pinMode(ledPin2, OUTPUT);
Video of lights blinking at the same time:
2. Can you control 2 lights with one potentiometer but have them controlled so that as one light gets dim, the other gets bright or one blinks fast while the other blinks slow
To do this I had to separate the code like the last time then add a delay to the second pin to make it blink after the other light. My guide book said that the sensor pin runs between 0 and 1023 so I had to make the delay more than 1023.
Video of lights blinking delay change:
Final Refection: Reflecting back on the process, it was again a challenge. I thought after last week it would be easier, but I still struggled. I have to be honest that with all the other work, I did wait until the second to last day to complete the challenge. I spend most of the day working on it, and felt defeated at times. I did feel more accomplished this week thought because I still struggled, and now feel more confident. This class has definitely been challenging and way out of my comfort zone. I am slowly building up my confidence, but when I start a new challenge I lose that confidence at first because I do fail each time. This is hard for me because when I start something I want it to work the first time, but this does not happen with making especially with coding and circuit boards. As I said in the readings part of making is failing, and the professor said that we will fail. The important part is to not give up which I wanted to do each time I failed. I kept working hard and thinking how to fix the problem. I eventually got each challenge to work and was very proud of myself.
Extension would be lights dimming or changing the blinking rate of lights. I also have these kinds of lights in my classroom. This is done by pushing a button to control the speed or brightness. I also think this could be used in remotes turning up the volume because in my guide book it gives the example of a MP3 player.
.jpg)

Comments
Post a Comment