Code Prompt with Chat-GPT¶
Introduction¶
For programming tasks in FabAcademy, I used a prompt structure that aims to generate code in a professional and well-documented engineering style.
The goal was not only to receive functional code, but to obtain code that is cleanly structured, technically sound, and suitable for real hardware implementation and later documentation.
In the context of FabAcademy, this is especially important because code should not appear as an isolated result, but as part of a transparent development process that can be tested, explained, and improved over time.
The prompt therefore focuses on several qualities at once: clear structure, practical usability, robust logic, meaningful comments, and a style that reflects real embedded programming rather than generic code generation. It should support an engineering workflow in which pin assignments, communication setup, initialization steps, and runtime behavior remain understandable at a glance. At the same time, the code should be written in a way that makes debugging easier and allows later extensions, for example when integrating sensors, wireless communication, or output devices into a larger system.
With the plus version, the Thinking function, and a good prompt, it is possible to get very good results, even though the generated code can sometimes be a bit confusing or unnecessarily complicated.
Therefore, for larger projects, I first explained the desired functionality before requesting the actual code.
Simple code example¶
I used this prompt for a support task: determining the MAC address of an ESP32-C3 supermini board before implementing wireless communication between two custom boards in week 11 - Networking and Communication.
Write an Arduino sketch for an ESP32-C3 supermini that prints the WiFi station MAC address to the serial monitor.
Use WiFi.h, initialize serial communication at 115200 baud, set the board to station mode, and print a short readable message before showing the MAC address.
Keep the code minimal, clean, and directly uploadable.
Add short comments in a professional FabAcademy style so the code is easy to document later.
Code:
#include <WiFi.h>
void setup() {
Serial.begin(115200);
delay(2000);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
Serial.println();
Serial.println("ESP32-C3 Receiver MAC Check");
Serial.print("WiFi STA MAC: ");
Serial.println(WiFi.macAddress());
Serial.println();
}
void loop() {
}
I flashed the code, and it worked right away. The MAC address was displayed, and even when error messages occurred, I could upload them to ChatGPT and get feedback.
This made it possible to implement most code quickly and easily.