Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- IRremote: modified from IRrecvDemo - demonstrates receiving IR codes with IRrecv
- and decodes specific messages
- An IR detector/demodulator must be connected to the input RECV_PIN.
- */
- // UP 1FE10EF
- // DOWN 1FED827
- #include <IRremote.h>
- // the receiver should be connected to this pin
- int RECV_PIN = 11;
- // delcare and initialize IRrecv object
- IRrecv irrecv(RECV_PIN);
- // decode_results object
- decode_results results;
- int ledPin = 9;
- int ledpin2 = 4;
- int bright = 50;
- void setup()
- {
- Serial.begin(9600);
- // In case the interrupt driver crashes on setup, give a clue
- // to the user what's going on.
- Serial.println("Enabling IRin");
- irrecv.enableIRIn(); // Start the receiver
- Serial.println("Enabled IRin");
- //
- // output to toggle on/off with receieved and decoded messages
- pinMode(ledPin, OUTPUT);
- pinMode (ledpin2, OUTPUT);
- }
- void loop() {
- digitalWrite(ledpin2, HIGH);
- analogWrite(ledPin,bright);
- if (irrecv.decode(&results)) {
- // print the value received and decoded
- Serial.println(results.value, HEX);
- //if the button press equals the hex value 0x....
- if (results.value == 0x1FE10EF)
- {
- bright = bright + 20;
- Serial.println("increase brightness");
- }
- else if (results.value == 0x1FED827)
- {
- bright = bright - 20;
- Serial.println("decrease brightness");
- }
- Serial.println(bright);
- irrecv.resume(); // Receive the next value
- }
- delay(100);
- }
Add Comment
Please, Sign In to add comment