Section 3.3 - Arduino C++ Programming


Let's write some code!

In this lesson, you’ll get hands-on with Arduino-based C++, learning to write code to control an LED through the Arduino. Starting with slides, you’ll be introduced to how Arduino code is structured, including key concepts like the initialize() and setup() functions that every Arduino program needs. Diagrams will help illustrate these core elements, making it easier to understand how code runs on the Arduino. In TinkerCAD, you’ll see the `initialize` and `setup` loops already pre-filled in the code editor, and you’ll learn where specific parts of the LED code should go. As you begin writing the LED control code, you’ll be introduced to commands like `pinMode`, which sets a pin as either an input or output. Finally, you’ll add a `delay` to make the LED blink at regular intervals, allowing you to see your code come to life as the LED turns on and off. This exercise provides a solid foundation in Arduino-based C++ and prepares you for future projects using code to control physical components.