定时器 — 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 plaino 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

hw_timer_t * timer_key = NULL;
void timer_ISR ()
{
  digitalWrite(BLUE_PIN, !digitalRead(BLUE_PIN));
  Serial.println("helo word");
}

void setup() {
  Serial.begin(115200);
  pinMode(LED_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
  
  timer_key = timerBegin(1000000);
  timerAttachInterrupt(timer_key,&timer_ISR);
  timerAlarm(timer_key,2000000,true,0);


  Serial.println("ESP32-C6 ready");
}

void loop() {
  digitalWrite(LED_PIN, HIGH); delay(500);
  digitalWrite(LED_PIN, LOW);  delay(500);
  Serial.println("tick");
}

More projects by yaxin