测试1 GPIO中断 — Esp32 C6 simulation

An interactive Esp32 C6 circuit simulation you can run free in your browser on Velxio, by yaxin.

Components

Sketch code

// ESP32-C6-DevKitC-1 - blink GPIO8 + serial log.
// GPIO8 also drives the board's WS2812 RGB LED; a plain external LED (through
// a 220R resistor to GND) on the same header pin is what this blinks.
#define LED_PIN 8
#define KEY_PIN 9
#define BLUE_PIN 10
int key=0;

void ISR ()
{
  Serial.println("heloword");
}

void setup() {
  Serial.begin(115200);
  pinMode(LED_PIN, OUTPUT);
  
  pinMode(KEY_PIN, INPUT_PULLUP);
  pinMode(BLUE_PIN, OUTPUT);
  attachInterrupt(KEY_PIN, ISR, FALLING);
  Serial.println("ESP32-C6 ready");
}

void loop() {
  key =digitalRead(KEY_PIN);
  digitalWrite(BLUE_PIN, !key);
  digitalWrite(LED_PIN, HIGH); delay(500);
  digitalWrite(LED_PIN, LOW);  delay(500);
  Serial.println("tick");
}

More projects by yaxin