Assignment 6.3
Post date: Aug 16, 2010 1:55:18 AM
I played around with the code for awhile and found a map setting that gave me a similar range as the potentiometer.
int potPin = 2; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600); //sends and receives data at 9600 bps
}
void loop() {
val = analogRead(potPin); // read the value from the sensor
val = map(val, 0, 301, 0, 1023);
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
Serial.println(val);
}