mirror of
				https://github.com/0xFEEDC0DE64/arduino-esp32.git
				synced 2025-10-30 21:51:40 +01:00 
			
		
		
		
	
		
			
	
	
		
			28 lines
		
	
	
		
			436 B
		
	
	
	
		
			Arduino
		
	
	
	
	
	
		
		
			
		
	
	
			28 lines
		
	
	
		
			436 B
		
	
	
	
		
			Arduino
		
	
	
	
	
	
|   | #include <Arduino.h>
 | ||
|  | #include <Ticker.h>
 | ||
|  | 
 | ||
|  | // attach a LED to GPIO 21
 | ||
|  | #define LED_PIN 21
 | ||
|  | 
 | ||
|  | Ticker tickerSetHigh; | ||
|  | Ticker tickerSetLow; | ||
|  | 
 | ||
|  | void setPin(int state) { | ||
|  |   digitalWrite(LED_PIN, state); | ||
|  | } | ||
|  | 
 | ||
|  | void setup() { | ||
|  |   pinMode(LED_PIN, OUTPUT); | ||
|  |   digitalWrite(1, LOW); | ||
|  |    | ||
|  |   // every 25 ms, call setPin(0) 
 | ||
|  |   tickerSetLow.attach_ms(25, setPin, 0); | ||
|  |    | ||
|  |   // every 26 ms, call setPin(1)
 | ||
|  |   tickerSetHigh.attach_ms(26, setPin, 1); | ||
|  | } | ||
|  | 
 | ||
|  | void loop() { | ||
|  | 
 | ||
|  | } |