34 lines
737 B
C++
34 lines
737 B
C++
#define LED1 12
|
|
#define LED2 14
|
|
hw_timer_t*My_timer1 = NULL;
|
|
hw_timer_t*My_timer2 = NULL;
|
|
int ledState1 = 0;
|
|
int ledState2 = 0;
|
|
|
|
void IRAM_ATTR onTimer1(){
|
|
ledState1 =! ledState1;
|
|
digitalWrite(LED1, ledState1);
|
|
}
|
|
|
|
void IRAM_ATTR onTimer2(){
|
|
ledState2 =! ledState2;
|
|
digitalWrite(LED2, ledState2);
|
|
}
|
|
|
|
void setup() {
|
|
pinMode(LED1, OUTPUT);
|
|
My_timer1 = timerBegin(0, 80, true);
|
|
timerAttachInterrupt(My_timer1, &onTimer1, true);
|
|
timerAlarmWrite(My_timer1, 1000000, true);
|
|
timerAlarmEnable(My_timer1);
|
|
pinMode(LED2, OUTPUT);
|
|
My_timer2 = timerBegin(1, 200, true);
|
|
timerAttachInterrupt(My_timer2, &onTimer2, true);
|
|
timerAlarmWrite(My_timer2, 1000000, true);
|
|
timerAlarmEnable(My_timer2);
|
|
}
|
|
|
|
void loop() {
|
|
//do nothing
|
|
}
|