// include the library code:
#include <LiquidCrystal.h>
#include <Adafruit_NeoPixel.h>
#define NUMPIXELS 7
#define NEOPIXEL1_PIN 4
#define NEOPIXEL2_PIN 0
#define NEOPIXEL3_PIN 2
#define NEOPIXEL4_PIN 15
#define DELAYVAL 500
#define BUTTON1_PIN 35
#define BUTTON2_PIN 34
#define BUTTON3_PIN 23
Adafruit_NeoPixel pixels1(NUMPIXELS, NEOPIXEL1_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels2(NUMPIXELS, NEOPIXEL2_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels3(NUMPIXELS, NEOPIXEL3_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels4(NUMPIXELS, NEOPIXEL4_PIN, NEO_GRB + NEO_KHZ800);
#define myled 12
// initialize the library by associating any needed LCD interface pin
// with the ESP32 pin number it is connected to
const int rs = 32, en = 33, d4 = 25, d5 = 26, d6 = 27, d7 = 14;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int i = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pixels1.begin();
pixels2.begin();
pixels3.begin();
pixels4.begin();
pinMode(BUTTON1_PIN, INPUT);
pinMode(BUTTON2_PIN, INPUT);
pinMode(BUTTON3_PIN, INPUT);
pinMode(myled, OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hello, world!");
}
void loop() {
buttonsPlay();
digitalWrite(myled, HIGH);
delay(500);
digitalWrite(myled, LOW);
delay(500);
delay(10); // this speeds up the simulation
}
void buttonsPlay() {
int button1State = 0;
int button2State = 0;
int button3State = 0;
button1State = digitalRead(BUTTON1_PIN);
button2State = digitalRead(BUTTON2_PIN);
button3State = digitalRead(BUTTON3_PIN);
Serial.print("button1 is ");
Serial.println(button1State);
Serial.print("button2 is ");
Serial.println(button2State);
Serial.print("button3 is ");
Serial.println(button3State);
}
void neopixelPlay() {
for(int i=0; i<NUMPIXELS; i++) {
pixels1.setPixelColor(i, pixels1.Color(0, 150, 0));
pixels2.setPixelColor(i, pixels2.Color(150, 0, 0));
pixels3.setPixelColor(i, pixels3.Color(0, 0, 150));
pixels4.setPixelColor(i, pixels4.Color(150, 150, 0));
pixels1.show();
pixels2.show();
pixels3.show();
pixels4.show();
delay(DELAYVAL);
}
pixels1.clear();
pixels2.clear();
pixels3.clear();
pixels4.clear();
}
void lcdPlay() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0);
// set the display to automatically scroll:
//lcd.autoscroll();
//lcd.scrollDisplayLeft();
lcd.print("Hello World!");
lcd.setCursor(0, 1);
lcd.print("this is a new line");
//lcd.println(i);
//i++;
delay(500);
// turn off automatic scrolling
//lcd.noAutoscroll();
// clear screen for the next loop:
lcd.clear();
}