SHARE
TWEET

Untitled

a guest Jan 21st, 2020 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Adafruit_NeoPixel.h>
  2.  
  3. #define NEW_PIXEL_PIN 7
  4. #define NUMPIXELS 48 // number of neo pixels
  5.  
  6. char state = '2';
  7.  
  8. Adafruit_NeoPixel pixels(NUMPIXELS, NEW_PIXEL_PIN, NEO_GRB + NEO_KHZ800);
  9.  
  10. void setup() {
  11.   Serial.begin(9600);
  12.   pixels.begin();
  13.   pixels.setBrightness(50);
  14.   pixels.clear();
  15. }
  16.  
  17. void loop() {
  18.   if (Serial.available() > 0) {
  19.     state = Serial.read();
  20.   }
  21.   if (state == '0') {
  22.     Serial.println("Code is incorrect!");
  23.     state = '2';
  24.     set_neo_pixel(false);
  25.     set_neo_pixel(false);
  26.     set_neo_pixel(false);
  27.   } else if (state == '1') {
  28.     Serial.println("Code is correct!");
  29.     state = '2';
  30.     set_neo_pixel(true);
  31.  
  32.     //    =========================
  33.     //    Implement the follwing lines according to instuctions
  34.     //    =========================
  35.   }
  36. }
  37.  
  38. void set_neo_pixel(bool debug) {
  39.   if (debug) {
  40.     pixels.fill(pixels.Color(0, 0, 255), 0, 48);
  41.   } else {
  42.     pixels.fill(pixels.Color(255, 0, 0), 0, 48);
  43.   }
  44.   pixels.show();
  45.   delay(500);
  46.   pixels.clear();
  47.   delay(500);
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top