add esp32s2 code

This commit is contained in:
lady ada 2021-12-27 17:30:17 -05:00
parent 5cf97f6053
commit e26491d9da

View file

@ -36,12 +36,21 @@
#define RED_LED 9
#define GREEN_LED 6
#define BLUE_LED 5
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
#define POWER_PIN 10
#define RED_LED 0
#define GREEN_LED 1
#define BLUE_LED 2
#define RED_PIN 11
#define GREEN_PIN 12
#define BLUE_PIN 13
#define analogWrite ledcWrite
#elif defined(ESP32)
#define POWER_PIN 33
#define RED_LED 0
#define GREEN_LED 1
#define BLUE_LED 2
#define RED_PIN 27
#define RED_LED 0
#define GREEN_LED 1
#define BLUE_LED 2
#define RED_PIN 27
#define GREEN_PIN 12
#define BLUE_PIN 13
#define analogWrite ledcWrite
@ -59,16 +68,17 @@ void setup() {
digitalWrite(POWER_PIN, LOW);
// Set up the LED Pins
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(BLUE_LED, OUTPUT);
#if defined(ESP32)
#if defined(ESP32) // and ESP32-S2!
ledcSetup(RED_LED, 5000, 8);
ledcAttachPin(RED_PIN, RED_LED);
ledcSetup(GREEN_LED, 5000, 8);
ledcAttachPin(GREEN_PIN, GREEN_LED);
ledcSetup(BLUE_LED, 5000, 8);
ledcAttachPin(BLUE_PIN, BLUE_LED);
#else
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(BLUE_LED, OUTPUT);
#endif
analogWrite(RED_LED, 0);
@ -104,5 +114,5 @@ void loop()
analogWrite(RED_LED, red);
analogWrite(GREEN_LED, green);
analogWrite(BLUE_LED, blue);
delay(100);
delay(2);
}