What the project is
supposed to do.
This week's project was a demonstration of how to vary the voltage
using a potentiometer in the circuit.
A potentiometer can be used to vary voltage using an analog resistance, rather than the
steady on or off state that is supplied from a digital signal. A digital signal has either an on or off
state (0 or 1) as in a light switch.
Using a potentiometer to vary the voltage from the analog side of the
board, you can regulate the voltage.
The code I used for this project.
int sensorPin = 0; // The
potentiometer is connected to// analog pin 0
int ledPin = 13; // The LED
is connected to digital pin 13
void setup() // this
function runs once when the sketch starts up
{pinMode(ledPin, OUTPUT);
}
void loop() // this function runs repeatedly after setup() finishes
{int sensorValue;
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(sensorValue); // Pause for sensorValue
// milliseconds
digitalWrite(ledPin, LOW); // Turn the LED off
delay(sensorValue); // Pause for sensorValue
// milliseconds
}
An Visio drawing of my electronic diagram of my week 2 project

A couple of YouTube Video of my project
Circuit and Code Play
See what happens if you use two digital pins rather that one digital and one analog pin:
I try to switch the analog pin over to digital, however the light would not function. I would think that a code change would be necessary in order for this to work. I will explore this a t a later time.
Extension Challenge
Can you control 2 lights with the same brightness or same blink rate
Yes, plugged a red LED into slot (g) 19 and 20 next to the amber LED and both blinked at the same rate.
Thoughts and Final Reflections:I found this project to fun and informative. The most challenging part of this project I encountered was having to go out and search the internet for the USK guide to get the proper code for this project. The code that I originally used, that I thought was the code for the project, did not work. Although I had a blinking light, the potentiometer was not working. I knew that there should have been some type of reaction when I turned the potentiometer, but there was no reaction. The light kept blinking at a steady rate.
What I learned from this project: I really never understood what component of the electronic circuitry controlled things like volume and attenuation (If that's a word). I now have a much better understanding of the hardware and software that controls the electronic circuitry.
Video explaining the
project and how it works.

No comments:
Post a Comment