In this article, I am going to show you an epic ESP32 Arduino simulator. You won't become an expert in ESP32 programming by the end of this article, But I am sure, you will get good hands-on. You will be more confident in planning and designing your next ESP32 project. You will use a free ESP32 simulator along so that you don't have to spend to learn about ESP32 programming. You don't have to install or download anything to start working with the ESP32 simulator.
A small introduction to ESP32 boards you will see aroundOut of these boards, the popular board is ESP32 and let us start to look at it in detail. also, before we delve into details, let us have a simple blink example as a starter :)
LED Blink ProjectProject summary: ESP32 LED blink project blinks an LED connected to the pin D2
every 500 ms
The code for the above project is given below
#define LED 2
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(500);
}
The live ESP32 project link - https://wokwi.com/arduino/projects/305566932847821378
You can try changing delay, LED colour or even create a nice pattern. You can start with the 'diagram.json' file. you can choose any standard colours for the LEDs.
Though the code seems similar to both Arduino and ESP32, the code on ESP32 will run at least 10 times faster.
If you need more help on using the Wokwi ESP32 simulator - https://www.hackster.io/Hack-star-Arduino/how-to-use-wokwi-arduino-simulator-what-is-wokwi-304e6b
ESP32 and 7 segment display ProjectProject summary: A 4 digit 7 segment display, is interfaced to ESP32. you can program in Arduino style, hence your code is written for Arduino projects would straight away run on ESP32 simulator!
Connection diagram
Simulator in action:
https://wokwi.com/arduino/projects/305567166302782017
Code
/**
ESP32 Seven Segment Counter Example
https://wokwi.com/arduino/projects/305567166302782017
*/
#include "SevSeg.h"
SevSeg sevseg;
void setup() {
byte numDigits = 4;
byte digitPins[] = {14, 15, 2, 5};
byte segmentPins[] = {12, 4, 19, 26, 27, 13, 18, 25};
bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
byte hardwareConfig = COMMON_ANODE; // See README.md for options
bool updateWithDelays = false; // Default 'false' is Recommended
bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
bool disableDecPoint = false; // Use 'true' if your decimal point doesn't exist or isn't connected. Then, you only need to specify 7 segmentPins[]
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
updateWithDelays, leadingZeros, disableDecPoint);
}
void loop() {
sevseg.setNumber(millis() / 100);
sevseg.refreshDisplay();
delay(1); // This speeds up the simulation
}
This is an ongoing article, I will be happy to share the concepts you would like more. Please leave your suggestion in the comment.
Comments