Guest User

Dumb Inside

a guest
Apr 3rd, 2016
171
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <code>
  2.  
  3.  #define rfReceivePin A0  //RF Receiver pin = Analog pin 0
  4.  #define ledPin 13        //Onboard LED = digital pin 13
  5.  #define ledPin1 7        //Onboard LED = digital pin 7
  6.  
  7.  unsigned int data = 0;   // variable used to store received data
  8.  const unsigned int upperThreshold = 600;  //upper threshold value
  9.  const unsigned int lowerThreshold = 600;  //lower threshold value
  10.  
  11. int a = 0;
  12. int b = 0;
  13.  
  14. void setup(){
  15.    pinMode(ledPin, OUTPUT);
  16.    pinMode(ledPin1, OUTPUT);
  17.    Serial.begin(9600);
  18.  }
  19.  
  20. void loop(){
  21.    data=analogRead(rfReceivePin);    //listen for data on Analog pin 0
  22.    if(data == 0)a=0;
  23.     if(data>upperThreshold){
  24.      digitalWrite(ledPin, LOW);   //If a LOW signal is received, turn LED OFF
  25.      Serial.println(data);
  26.      a=a+1;
  27.    if( a > 100)digitalWrite(ledPin1, HIGH);
  28.    }
  29.    if(data<lowerThreshold){
  30.      digitalWrite(ledPin, HIGH);   //If a HIGH signal is received, turn LED ON
  31.      Serial.println(data);
  32.      b=b+1;
  33.      if( b > 2)digitalWrite(ledPin1, LOW);
  34.    }
  35.  }
  36. </code>
RAW Paste Data