Arduino Code¶
Arduino code is the program that runs on your microcontroller and controls sensors, actuators, and communication with other systems. With your code you read sensor values, make decisions, and control outputs such as LEDs, motors, or relays. Good Arduino code is structured, readable, and easy to extend when your embedded system grows more complex.
For this product, you describe how your Arduino (or compatible) code is structured, how it interacts with the hardware, and how you keep it maintainable and testable.
Arduino Code in Embedded & IoT Systems¶
Typical tasks of Arduino code in an embedded or IoT project include:
- Initialising sensors, actuators, and communication interfaces
- Reading sensor data and applying basic filtering or calibration
- Making decisions based on thresholds, states, or received messages
- Controlling outputs such as LEDs, buzzers, displays, motors, or relays
- Communicating with other devices (for example via serial, I²C, SPI, or Wi-Fi)
You structure your code so that these responsibilities are clearly separated and easy to understand.
Quality indicators¶
When assessing this product, the following quality indicators will be considered:
- The Arduino code document is self-contained, starting with an introduction/context and then describing the code structure.
- It clearly describes what the code does at a high level (behaviour of the system).
- It explains how the code is organised (for example functions, files, classes, libraries).
- It describes how sensors and actuators are initialised and used in the code.
- It shows how timing is handled (for example non-blocking code using
millis()instead of longdelay()calls, where appropriate). - It includes code snippets that demonstrate key parts of the implementation, with references to the full code in GitLab.
- It mentions any external libraries used and why they were chosen.
- It includes a list of sources used to learn and write the Arduino code.
Template¶
To document Arduino code for your own project, you can use the following template:
# Arduino Code
In this section, describe in a few sentences what your Arduino sketch does and which problem it solves. This is the main text of your document.
## Overview of Behaviour
Here you describe, in plain language:
- Which inputs (sensors, buttons, communication) the system uses
- Which outputs (LEDs, motors, relays, displays) it controls
- How the system reacts to different situations
## Code Structure
Here you describe how the code is organised:
- How `setup()` and `loop()` are structured
- Which extra functions or classes you use
- How you avoid duplicating code
Add code snippets that illustrate the structure and reference the full sketch in GitLab.
## Hardware Interaction
Here you describe how sensors and actuators are used in the code:
- How pins are configured
- How sensor values are read and possibly filtered
- How outputs are controlled based on inputs or logic
## Timing & Reliability
Here you describe how timing is handled:
- Use of `millis()` or timers instead of long `delay()` calls (if applicable)
- Any debouncing of buttons or handling of noisy signals
## Libraries & Sources
Here you list:
- External libraries you use (name and purpose)
- Sources you used to learn and implement the code (documentation, tutorials, example sketches, videos, etc.)