Fecha de publicación: 14-ene-2016 15:53:33
Montaje en 123DCircuits:
Código en Arduino:
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led1 = 2;
int led2 = 4;
int valorpot;
int potPin = A5;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(potPin, INPUT);
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop()
{
valorpot = analogRead(potPin);
if (valorpot<=500)
{
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
}
else
{
digitalWrite(led1, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(led2, HIGH); // turn the LED off by making the voltage LOW
}
}
Vídeo del funcionamiento: