#include <Adafruit_NeoPixel.h>
const byte data_pin = 15;
const byte pir_pin = 2 ;
const byte led_num = 16;
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(led_num, data_pin, NEO_GRB+ NEO_KHZ800);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(pir_pin, INPUT);
pixels.begin();
pixels.show();
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(digitalRead(pir_pin));
if( digitalRead(pir_pin) ){
generate_random_pattern();
}
delay(10); // this speeds up the simulation
}
void generate_random_pattern(){
pixels.setPixelColor(0,255,0,0);
pixels.show();
}