Technology

ChatGPT Develops Arduino Drivers Inspired by Adafruit’s Ladyada

ChatGPT Develops Arduino Drivers Inspired by Adafruit’s Ladyada

It’s a significant work to write libraries to support our favorite microcontrollers, but what if ChatGPT could help? Limor “Ladyada” Fried of Adafruit has entrusted ChatGPT with writing Arduino drivers in her own way, producing a “mini-Limor” bot to undertake the task.

Ladyada devotes a significant amount of time to building Arduino libraries and has created hundreds of libraries to support Ada fruit’s impressive variety of boards (many of which are featured on our top Grove and Stemma QT page). Many of Adafruit’s drivers, which can be accessible on GitHub, have already been used to train GPT-4. These drivers are written in the “Ladyada style” (Adafruit_BusIO), which implies they can be used to construct drivers.

The pipeline includes numerous datasheet references, binary tables, and bit insets that must all be understood and transformed into C or Python code. This is not an easy task (believe us, we tried it). There is no standard format for obtaining this information. Datasheets might differ greatly.

ChatGPT-Develops-Arduino-Drivers-Inspired-by-Adafruits-Ladyada
ChatGPT Develops Arduino Drivers Inspired by Adafruit’s Ladyada

Fried’s methodology for “mini-Limor” is asking ChatGPT to “[write] an Arduino library in the same style as ladyada / limor fried.” Fried instructs ChatGPT to write a driver for the VCNL4020 ambient light and infrared sensor, which is an I2C-based sensor. The workflow uses a free PDF parsing plugin (AI PDF) to read a datasheet and extract register names, values, enum tables, and text for comments.

Fried then instructs ChatGPT to generate a skeleton file for the VCNL4020, which it does partially. Then Fried instructs it to construct the registers using data from the datasheet. Fried then moves on to creating the library.

Is this a quicker procedure? No, it does not. According to Adafruit’s blog post, “the amount of time it takes ChatGPT to write a driver is about the same as Ladyada,” and the resulting driver requires human interaction to ensure its validity, as Fried states in the video. However, it does free up Fried to work on other projects.

Although the work generated is based on Adafruit’s earlier work, Adafruit has confirmed that any Large Language Model (LLM) used would be disclosed and linked to.

Good drivers provide a foundation for learners to gain experience without getting too technical, especially with I2C, SPI, and a variety of other protocols. If the method can be polished and automated, it could aid developers like Adafruit in creating drivers and libraries for several popular programming languages. The method might be applied to third-party software support for the Arduino Uno R4 family of boards. Fried also notes that this technique may be utilized with CircuitPython, which implies that the Raspberry Pi Pico family of boards can be used.