Blinky with Arduino on ESP32-C3

Updated on 17 November 2023
dev board ESP32-C3-DevKitM-1
chip ESP32-C3-MINI-1-N4
features blinky led serial esp32c3

Before starting

Dependancies

Ensure the following dependancies are downloaded and available:

Pre-requisites

Try these simpler or similar examples:

Buy the components

Code

Download code blinky-arduino-esp32c3.ino
// Switch LED between an external LED or the on-board LED
// #define LED LED_BUILTIN
#define LED 3

void setup() {
  pinMode(LED, OUTPUT);
  digitalWrite(LED, LOW);

  Serial.begin(115200);
  Serial.println("Start blinky");
}

void loop() {
  ledON();
  delay(200);

  ledOFF();
  delay(200);
}

void ledON() {
  Serial.println("LED ON");
  digitalWrite(LED, LOW);
}

void ledOFF() {
  Serial.println("LED OFF");
  digitalWrite(LED, HIGH);
}

Makefile

BOARD?=esp32:esp32:esp32c3
PORT?=/dev/cu.SLAB_USBtoUART*
BUILD=build

.PHONY: default lint all flash clean

default: lint all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

all:
	arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./

flash:
	arduino-cli upload --fqbn $(BOARD) --port $(PORT) --input-dir $(BUILD)

clean:
	rm -r build

Prototype

A photo of the actual setup.

Blinky with Arduino on ESP32-C3 prototype

Arduino IDE settings

Ensure the following IDE settings before flashing.

Blinky with Arduino on ESP32-C3 Arduino IDE settings

Serial console

Serial output from the firmware.

Blinky with Arduino on ESP32-C3 serial console

Description

The on-board LED LED_BUILTIN is GPIO8 as defined in the pin out.

Compile and upload the firmware via the Arduino IDE or arduino-cli with Makefile.

References

Watch