1
- // Copyright 2023 Espressif Systems (Shanghai) PTE LTD
1
+ // Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2
2
//
3
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
4
// you may not use this file except in compliance with the License.
13
13
// limitations under the License.
14
14
15
15
/* *
16
- * @brief This example demonstrate how to use RMT to just blink a regular LED (GPIO)
17
- * It uses all the different RMT Writing APIs to blink the LED by hardware, not being
18
- * necessary the regular Blink code in Arduino.
19
- *
20
- * The output is the Blinking LED in the GPIO and a serial output describing what is
21
- * going on, along the execution.
22
- *
23
- * The circuit is just a LED and a resistor of 270 ohms connected to the GPIO
24
- * GPIO ---> resistor 270 ohms ---> + LED - ---> GND
25
- */
16
+ @brief This example demonstrate how to use RMT to just blink a regular LED (GPIO)
17
+ It uses all the different RMT Writing APIs to blink the LED by hardware, not being
18
+ necessary the regular Blink code in Arduino.
19
+
20
+ The output is the Blinking LED in the GPIO and a serial output describing what is
21
+ going on, along the execution.
22
+
23
+ The circuit is just a LED and a resistor of 270 ohms connected to the GPIO
24
+ GPIO ---> resistor 270 ohms ---> + LED - ---> GND
25
+ */
26
26
27
27
#define BLINK_GPIO 2
28
28
@@ -232,15 +232,15 @@ void RMT_Mixed_Write_Blink() {
232
232
Serial.println (" ===> rmtWrite() (Blocking Mode) to Blink the LED." );
233
233
Serial.println (" Blinking at 500ms on + 500ms off :: 4 blinks" );
234
234
for (uint8_t i = 0 ; i < 4 ; i++) {
235
- if (!rmtWrite (BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF (blink_500ms_rmt_data) - 2 , RMT_WAIT_FOR_EVER)) {
235
+ if (!rmtWrite (BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF (blink_500ms_rmt_data) - 1 , RMT_WAIT_FOR_EVER)) {
236
236
Serial.println (" ===> rmtWrite Blink 0.5s Error!" );
237
237
}
238
238
}
239
239
240
240
Serial.println (" ===> rmtWriteAsync() (Non-Blocking Mode) to Blink the LED." );
241
241
Serial.println (" Blinking at 250ms on + 250ms off :: 5 blinks" );
242
242
for (uint8_t i = 0 ; i < 5 ; i++) {
243
- if (!rmtWriteAsync (BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF (blink_250ms_rmt_data) - 2 )) {
243
+ if (!rmtWriteAsync (BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF (blink_250ms_rmt_data) - 1 )) {
244
244
Serial.println (" ===> rmtWrite Blink 0.25s Error!" );
245
245
}
246
246
// wait (blocks) until all the data is sent out
@@ -267,9 +267,11 @@ void RMT_Loop_Write_Blink() {
267
267
Serial.println (" ===> rmtWriteLooping Blink 0.25s Error!" );
268
268
}
269
269
delay (5000 );
270
+
270
271
Serial.println (" Blinking OFF for 2 seconds" );
271
- if (!rmtWriteLooping (BLINK_GPIO, NULL , 0 )) {
272
- Serial.println (" ===> rmtWriteLooping Blink OFF Error!" );
272
+ rmt_data_t blink_STOP_rmt_data[] = { {0 , 0 , 0 , 0 } };
273
+ if (!rmtWrite (BLINK_GPIO, blink_STOP_rmt_data, RMT_SYMBOLS_OF (blink_STOP_rmt_data), RMT_WAIT_FOR_EVER)) {
274
+ Serial.println (" ===> rmtWrite Blink STOP Error!" );
273
275
}
274
276
delay (2000 );
275
277
}
@@ -278,19 +280,19 @@ void RMT_Single_Write_Blocking_Blink() {
278
280
Serial.println (" Using RMT Writing and its Completion to blink an LED." );
279
281
Serial.println (" Blinking at 1s on + 1s off :: 2 blinks" );
280
282
for (uint8_t i = 0 ; i < 2 ; i++) {
281
- if (!rmtWrite (BLINK_GPIO, blink_1s_rmt_data, RMT_SYMBOLS_OF (blink_1s_rmt_data) - 2 , RMT_WAIT_FOR_EVER)) {
283
+ if (!rmtWrite (BLINK_GPIO, blink_1s_rmt_data, RMT_SYMBOLS_OF (blink_1s_rmt_data) - 1 , RMT_WAIT_FOR_EVER)) {
282
284
Serial.println (" ===> rmtWrite Blink 1s Error!" );
283
285
}
284
286
}
285
287
Serial.println (" Blinking at 500ms on + 500ms off :: 4 blinks" );
286
288
for (uint8_t i = 0 ; i < 4 ; i++) {
287
- if (!rmtWrite (BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF (blink_500ms_rmt_data) - 2 , RMT_WAIT_FOR_EVER)) {
289
+ if (!rmtWrite (BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF (blink_500ms_rmt_data) - 1 , RMT_WAIT_FOR_EVER)) {
288
290
Serial.println (" ===> rmtWrite Blink 0.5s Error!" );
289
291
}
290
292
}
291
293
Serial.println (" Blinking at 250ms on + 250ms off :: 8 blinks" );
292
294
for (uint8_t i = 0 ; i < 8 ; i++) {
293
- if (!rmtWrite (BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF (blink_250ms_rmt_data) - 2 , RMT_WAIT_FOR_EVER)) {
295
+ if (!rmtWrite (BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF (blink_250ms_rmt_data) - 1 , RMT_WAIT_FOR_EVER)) {
294
296
Serial.println (" ===> rmtWrite Blink 0.25s Error!" );
295
297
}
296
298
}
@@ -302,23 +304,23 @@ void RMT_Write_Aync_Non_Blocking_Blink() {
302
304
Serial.println (" Using RMT Async Writing and its Completion to blink an LED." );
303
305
Serial.println (" Blinking at 1s on + 1s off :: 5 blinks" );
304
306
for (uint8_t i = 0 ; i < 5 ; i++) {
305
- if (!rmtWriteAsync (BLINK_GPIO, blink_1s_rmt_data, RMT_SYMBOLS_OF (blink_1s_rmt_data) - 2 )) {
307
+ if (!rmtWriteAsync (BLINK_GPIO, blink_1s_rmt_data, RMT_SYMBOLS_OF (blink_1s_rmt_data) - 1 )) {
306
308
Serial.println (" ===> rmtWrite Blink 1s Error!" );
307
309
}
308
310
// wait (blocks) until all the data is sent out
309
311
while (!rmtTransmitCompleted (BLINK_GPIO));
310
312
}
311
313
Serial.println (" Blinking at 500ms on + 500ms off :: 5 blinks" );
312
314
for (uint8_t i = 0 ; i < 5 ; i++) {
313
- if (!rmtWriteAsync (BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF (blink_500ms_rmt_data) - 2 )) {
315
+ if (!rmtWriteAsync (BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF (blink_500ms_rmt_data) - 1 )) {
314
316
Serial.println (" ===> rmtWrite Blink 0.5s Error!" );
315
317
}
316
318
// wait (blocks) until all the data is sent out
317
319
while (!rmtTransmitCompleted (BLINK_GPIO));
318
320
}
319
321
Serial.println (" Blinking at 250ms on + 250ms off :: 5 blinks" );
320
322
for (uint8_t i = 0 ; i < 5 ; i++) {
321
- if (!rmtWriteAsync (BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF (blink_250ms_rmt_data) - 2 )) {
323
+ if (!rmtWriteAsync (BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF (blink_250ms_rmt_data) - 1 )) {
322
324
Serial.println (" ===> rmtWrite Blink 0.25s Error!" );
323
325
}
324
326
// wait (blocks) until all the data is sent out
@@ -345,7 +347,6 @@ void setup() {
345
347
346
348
RMT_Mixed_Write_Blink ();
347
349
Serial.println (" End of Mixed Calls testing" );
348
- delay (1000 );
349
350
350
351
Serial.println (" \n ===============================" );
351
352
Serial.println (" Starting a Blinking sequence..." );
0 commit comments