Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <IRLib.h>
- #include <Adafruit_NeoPixel.h>
- #ifdef __AVR__
- #include <avr/power.h>
- #endif
- #define PIN 6
- #define NUMPIXELS 4
- #define VIBRO 7
- #define RECV_PIN 8
- int delayval = 500;
- IRrecv My_Receiver(RECV_PIN);
- IRdecode My_Decoder;
- Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
- void setup()
- {
- #if defined (__AVR_ATtiny85__)
- if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
- #endif
- Serial.begin(9600);
- My_Receiver.enableIRIn();
- pixels.begin();
- pinMode(VIBRO, OUTPUT);
- }
- void loop() {
- int hp = 100;
- int dmg = 25;
- int maxHp = 255;
- int minHp = 0;
- if (My_Receiver.GetResults(&My_Decoder)) {
- My_Decoder.decode();
- while (hp <= 0 ){
- pixels.setPixelColor(4, pixels.Color(minHp,maxHp,0));
- Serial.print(pixels);
- hp = hp-10;
- maxHp = maxHp-dmg;
- minHp = minHp+dmg;
- }
- digitalWrite(VIBRO, HIGH);
- pixels.show();
- delay(500);
- }
- My_Receiver.resume(); //Restart the receiver
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement