rubenelportero

modulo RF (Receiver)

May 11th, 2015
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. // http://ingenieroaburrido.com
  2.  
  3. #define rfReceivePin A0  //RF Receiver pin = pin analógico 0
  4. #define ledPin 13        //LED de la arduino = digital pin 13
  5.  
  6.  unsigned int data = 0;   // variable usada para almacenar los datos.
  7.  const unsigned int upperThreshold = 50;  //upper threshold value
  8.  const unsigned int lowerThreshold = 50;  //lower threshold value
  9.  
  10.  void setup(){
  11.    pinMode(ledPin, OUTPUT);
  12.    Serial.begin(9600);
  13.  }
  14.  
  15.  void loop(){
  16.    data=analogRead(rfReceivePin);    //esperando a recibir datos por el pin analógico...
  17.    
  18.     if(data>upperThreshold){
  19.      digitalWrite(ledPin, HIGH);   //Si la señal es alta, encendemos el LED
  20.      Serial.println(data);
  21.    }
  22.    
  23.    if(data<lowerThreshold){
  24.      digitalWrite(ledPin, LOW);   //Si la señal es baja, apagamos el LED
  25.      Serial.println(data);
  26.    }
  27.  }
Advertisement
Add Comment
Please, Sign In to add comment