Receptor IR

CÓDIGO
/*
Receptor IR 
*/
#define LED 2
#define Opto 3

int Opto_lee = 0;
int estadoLed = 0;
int estadoAnterior = 0;

void setup() {
  pinMode(LED,OUTPUT);
  pinMode(Opto,INPUT);
}

void loop() {
  Opto_lee = digitalRead(Opto);
  
if((Opto_lee == 1)&&(estadoAnterior == 0)){
  estadoLed = 1 - estadoLed ;
  delay(200); //AntiRebote
  }
  estadoAnterior = Opto_lee;
  if(estadoLed == 1){
    digitalWrite(LED,HIGH);
    }else{
      digitalWrite(LED,LOW);
      }
}

MATERIALES
1 ARDUINO
1 VS1838B
1 Led 5mm
1 Resistencia 220 ohm
Protoboard
Jumpers

CIRCUITO

Compartir en Google Plus

About habacuc.electronics

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Comentario Blogger
    Comentario Facebook