Lina Maria Giraldo's Blog

Multimedia Artist and ITP Student

Archive for the ‘Analog input’ tag

Analog Input, Getting Creative, Love meter 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 Greenled = 9;    // PWM pin that the GreenLED is on.  n.b. PWM 0 is on digital pin 9

int Yellowled = 10;    // PWM pin that the YellowLED is on. 

int Redled = 11;    // PWM pin that the redLED is on.

 

void setup() {

// initialize serial communications at 9600 bps:

Serial.begin(9600);

pinMode(Greenled,OUTPUT);

pinMode(Yellowled,OUTPUT);

pinMode(Redled,OUTPUT);

}

 

void loop() {

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

Serial.println(potValue);

 

if(100 <= potValue && potValue < 441)

{

  digitalWrite(Greenled,HIGH);

  digitalWrite(Yellowled,LOW);

  digitalWrite(Redled,LOW);

}

else if(441 <= potValue && potValue < 782)

{

  digitalWrite(Greenled,HIGH);

  digitalWrite(Yellowled,HIGH);

  digitalWrite(Redled,LOW);

}

else if(potValue >= 782)

{

  digitalWrite(Greenled,HIGH);

  digitalWrite(Yellowled,HIGH);

  digitalWrite(Redled,HIGH);

}

else

{

  digitalWrite(Greenled,LOW);

  digitalWrite(Yellowled,LOW);

  digitalWrite(Redled,LOW);

}

 

/*

if (0 < potValue <341) {

analogWrite(Greenled, potValue/4);  // PWM the Green LED 

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

}

 if (201 <potValue <682) {

analogWrite(Yellowled, potValue/4);  // PWM the Yellow LED 

delay(10);  

 

 

}

if (401<potValue <1023) {

analogWrite(Redled, potValue/4);  // PWM the Yellow LED 

delay(10); 

}*/

}

Written by admin

February 4th, 2009 at 3:56 pm

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