Friday 27 November 2015

Lab 4 - Potentiometer

Purpose:
To change the intervals between blinks of the LED

Equipment:
Potentiometer (X1)
resistor (X1)
LED (X1)
wires (X6)

Program Details:
I used the one of newinnovators.ca

Time to Program and Complete:
5 minutes

Results:
i have to move the potentiometer so it would fit

Photo/Video Proof:
Photo or video of you actually doing this lab



























Program:
int sensorPin = A0;
//assigns sensorPin to analog pin 0
int ledPin = 13;
//sets ledPin to pin 13
int sensorValue = 0;
//sets a value for sensorValue

void setup()
//declares a setup
{
//start of function
  pinMode(ledPin, OUTPUT);

//sets ledPin as an output
}
//end of function

void loop()
//declares a loop
{
// start of loop
  sensorValue = analogRead(sensorPin);
//gives sensorValue a value of what sensorPin is currently at
  digitalWrite(ledPin, HIGH);
//sets the LED to maximum power
  delay(sensorValue);
//delays the code for the value of sensorValue
  digitalWrite(ledPin, LOW);
//sets the LED to minimum power
  delay(sensorValue);
//delays the code for the value of sensorPin
}
//end of loop

Program Modifications:
N/A

Helpful Tips:
Make sure the wires go to the correct ports and pins

References:
newinnovators.ca

No comments:

Post a Comment