materials for TeZ Bioreactor course
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2 KiB

  1. // WEMOS D1 MINI ESP32 // NEOPIXEL TEST (RGB) // TeZ 2022
  2. #include <Adafruit_NeoPixel.h>
  3. #define PIN 5 // data pin for neopixel
  4. #define NUMPIXELS 8 // Max number of Leds
  5. int rgbflag = 1;
  6. Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  7. #define DELAYVAL 50 // Time (in milliseconds) to pause between pixels
  8. int ledPin = 2; // internal led D1 Mini esp32
  9. //////////////////////////////////
  10. void setup() {
  11. pinMode(ledPin, OUTPUT);
  12. pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  13. }
  14. //////////////////////////////////
  15. void loop() {
  16. pixels.clear(); // Set all pixel colors to 'off'
  17. for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
  18. if(rgbflag == 1){
  19. pixels.setPixelColor(i, pixels.Color(200, 0, 0)); // RED
  20. }else if(rgbflag == 2){
  21. pixels.setPixelColor(i, pixels.Color(0, 200, 0)); // GREEN
  22. }else if(rgbflag == 3){
  23. pixels.setPixelColor(i, pixels.Color(0, 0, 200)); // BLUE
  24. }
  25. pixels.show(); // Send the updated pixel colors to the hardware.
  26. digitalWrite(ledPin, HIGH); // internal led ON
  27. delay(DELAYVAL);
  28. digitalWrite(ledPin, LOW); // internal led OFF
  29. delay(DELAYVAL);
  30. }
  31. if(rgbflag < 3){
  32. rgbflag ++;
  33. }else{
  34. rgbflag = 1;
  35. }
  36. }