Lina Maria Giraldo's Blog

Multimedia Artist and ITP Student

Analog Input week 2 (1)

without comments

 

Click on the image

Click on the image

 int potPin = 0;    // Analog input pin that the potentiometer is attached to

int potValue = 0;   // value read from the pot

int led = 9;    // PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9

 

void setup() {

  // initialize serial communications at 9600 bps:

  Serial.begin(9600); 

}

 

void loop() {

  potValue = analogRead(potPin); // read the pot value

  analogWrite(led, potValue/4);  // PWM the LED with the pot value (divided by 4 to fit in a byte)

  Serial.println(potValue);      // print the pot value back to the debugger pane

  delay(10);                     // wait 10 milliseconds before the next loop

}


Analog Input using a potentiometer from Lina Giraldo on Vimeo.

Written by admin

February 4th, 2009 at 3:20 pm

Leave a Reply

You must be logged in to post a comment.