Advertisement
Guest User

ard

a guest
Mar 5th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <IRLib.h>
  2.  
  3. #include <Adafruit_NeoPixel.h>
  4. #ifdef __AVR__
  5.   #include <avr/power.h>
  6. #endif
  7.  
  8. #define PIN            6
  9. #define NUMPIXELS      4
  10. #define VIBRO          7
  11. #define RECV_PIN       8
  12.  
  13. int delayval = 500;
  14. IRrecv My_Receiver(RECV_PIN);
  15. IRdecode My_Decoder;
  16. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  17.  
  18. void setup()
  19. {
  20.  
  21. #if defined (__AVR_ATtiny85__)
  22.   if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  23. #endif
  24.  
  25.   Serial.begin(9600);
  26.   My_Receiver.enableIRIn();
  27.    pixels.begin();
  28.    pinMode(VIBRO, OUTPUT);
  29. }
  30.  
  31. void loop() {
  32. int hp = 100;
  33. int dmg = 25;
  34. int maxHp = 255;
  35. int minHp = 0;
  36.  
  37.   if (My_Receiver.GetResults(&My_Decoder)) {
  38.    My_Decoder.decode();
  39.     while (hp <= 0 ){
  40.      pixels.setPixelColor(4, pixels.Color(minHp,maxHp,0));
  41.      Serial.print(pixels);
  42.          hp = hp-10;
  43.          maxHp = maxHp-dmg;
  44.          minHp = minHp+dmg;
  45.          }
  46.          digitalWrite(VIBRO, HIGH);
  47.          pixels.show();
  48.          delay(500);
  49.  }
  50.  My_Receiver.resume();     //Restart the receiver
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement