Lesson 9: Advanced Concepts and Projects – Circuits and Coding 101
📌 Introduction
Welcome back to Lesson 9 of Circuits and Coding 101! Today, we’re diving into advanced programming and electronics concepts to take your projects to the next level.
This lesson combines object-oriented programming, state machines, and hardware integration to build smarter systems.
🎯 What You’ll Learn Today
- Object-Oriented Programming (OOP) – Organizing code into reusable objects
- State Machines – Structuring multi-step logic
- ESP32 Wi-Fi Communication – Sending data over the web
- Hands-on exercises – Controlling components using advanced techniques
🚀 Setting Up the T-Display ESP32
Quick Start Guide
Follow these steps to set up your T-Display ESP32 in the Arduino IDE:
- Copy the
TFT_eSPIlibrary to your Arduino libraries directory (C:\Users\YourUserName\Documents\Arduino\libraries). - In the Arduino IDE, go to
File > Examples > TFT_eSPIand open theFactoryTestexample. - In the
Toolsmenu, set:- Board: ESP32 Dev Module
- PSRAM: Disable
- Flash Size: 4MB
- Select the correct serial port and click Upload.
🔍 Object-Oriented Programming (OOP)
What is OOP? OOP organizes code into reusable objects to make programs modular and scalable.
💻 Example: Defining an LED Object
🛠️ State Machines
What is a State Machine? It structures complex logic by organizing it into states and transitions.
💡 Hands-On Exercise: Traffic Light State Machine
🌐 Wireless Communication with ESP32
Using the ESP32, we can send and receive data over Wi-Fi.
💻 Hands-On Exercise: Display Sensor Data on a Web Page
📺 Using OLED Displays
We’ll use an OLED to display live sensor readings.
💡 Hands-On Exercise: Temperature Display