Monday, November 16, 2009

fotocelda + dos salidas digitales

int potPin = 0; // select the input pin for the potentiometer
int val = 0; // variable to store the value coming from the sensor
int led1=7; // digital output 1
int led2=6; // digital output2
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
Serial.begin(9600);
}

void loop() {
val = analogRead(potPin); // read the value from the sensor
if(val >= 512){
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
}else{
digitalWrite(led2, HIGH);
digitalWrite(led1, LOW);
}
delay(200);
}







No comments:

Post a Comment