Week 2 Maker spacer challenge
1. Explanation of the project:
The purpose of this week’s challenge is to use the potentiometer
as a means to control the blinking of the LED light. As the potentiometer is turned, the blinking
speeds up or slows down.
2. The following is the code that was used
The following is the code that was used.
/* SparkFun Inventor's Kit
Example sketch 02
void setup() // this function runs once when the sketch starts up
{
// We'll be using pin 13 to light a LED, so we must configure it
// as an output.
// Because we already created a variable called ledPin, and
// set it equal to 13, we can use "ledPin" in place of "13".
// This makes the sketch easier to follow.
pinMode(ledPin, OUTPUT);
void loop() // this function runs repeatedly after setup() finishes
{
// First we'll declare another integer variable
// to store the value of the potentiometer:
int sensorValue;
sensorValue = analogRead(sensorPin);
// Note that we're using the ledPin variable here as well:
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
// Remember that loop() repeats forever, so we'll do all this
// again and again.
3. Arduino and Breadboard
2. Here is an electron diagram and picture of the circuit board.
5. Visual explanation of the potentiometer
1. Additional Challenges:
Circuit and Code Play
1. 1. See
what happens if you use two digital pins rather than on digital and one analog
pin.
2. See what happens if you use
two analog pins rather than one digital and one analog pin.
The LED light stops working
The LED light stops working completely.


Comments
Post a Comment