AI and Arduino and code/application generation in general. A future perspective now

I found this, IMHO, quite remarkable video from an, up until very recently, quite prolific Arduino blogger: Andreas Spiess. Principally, he has gone "full AI" and has reached the point where he never needs to touch a line of code. The video is here (26 minutes) : https://www.youtube.com/watch?v=5DG0-_lseR4 . I'm usually hesitant to recommend videos but this one I find quite special and the guy has a good reputation.

He describes this adventure in a sort of pyramid of achievement, climbing higher with each step.

He starts at the stage that most of us already know of a cycle of simply copying and pasting some half attempt at coding into an AI, testing and reporting back any errors where, hopefully, the next round get closer to a solution. We know this from either our own experience or from seeing others who are clearly using AI for some of the problems they present on this site.

He then progresses on to a concept of simply specifying the required functionality of the required solution in some unambiguous way, together with any necessary constraints, and feeding that to the AI.

Incidentally, he mentions "Claude" quite a lot.

He then goes onto AI agents. This really gets interesting. Here the agents have a degree of control over the development environment and can progress from merely suggesting code changes, but go on to push them into the development process, independently fix compilation errors etc., go on to execute test cases and finally publish the code on say github also including documentation. There is also a lot of discussion about constraining the limits/access rights of the agents to limit the damage they can do in a failure case.

He also talks about moving away from the classic Arduino IDE to command line and CLI based development because this is easier for these AI agents to interface with.

Anyway, maybe someone finds this interesting.

  • One reason why it’s comforting to know I have less then 15 years left.

:face_with_crossed_out_eyes:

1 Like

I am only half way through that video but will watch the rest mainly because of the presenters reputation.
Earlier Bill over at DronBot Workshop did a video about designing with AI and the use of multiple Ais and very long prompts. Here is his VIDEO

Interesting links! Thanks @6v6gt and @sonofcy .

When I challenged AI (ChatGPT) to make some Arduino code some years ago, the experience was quite different from my recent test. Back then it generated code that didn’t work as it was missing some essential functionality. The part that was somewhat working seemed to be copied, pasted and combined from examples published elsewhere.

Quite recently I had another go. This time it was with Gemini and I saw that technology had progressed quite a bit. Not only did it generate working examples, it also gave some creative suggestions. The dialog felt like working with a willing assistent that only needed some minor nudging to get the desired result.

For those interested: the example made using Gemini was an AdafruitGFX based Holiday animation on an 11x11 RGB LED matrix driven by a TM1680. I kept my prompts pretty short, but the entire conversation spanned a couple of hours during which I tested generated code and tried some manual modifications.

I could easily copy and paste the generated code into the Arduino IDE and ask for changes after compilation and testing. At one point, without me even asking, it generated an image to illustrate the animated scene. In general I enjoyed the experience and think it saved me from spending many pixel-nudging change-compile-test iterations.

You thought it was something else? Those LLMs are ginormous collections of almost everything you, I, and the millions of internet users type at a screen. Plus, they (all the AIs) have copies of all sorts of data.

Originally, ChatGPT did not use the internet in its responses; now I see it does, as it tells me when it is 'thinking' about an answer to my prompt.

I use an AI pretty much daily. Most Google searches I enter into the box that almost always summons the Google AI (as opposed to the wonder bar or whatever it's called, where you can enter a URL)

I used it to organize my medication due to timing and interactions. I don't trust myself anymore at 83. I recently asked it for recommendations on a bookmark organizer tool, and we finally settled on one. For a while, I thought it might have AI, but we decided against it and went with a different, more mainstream tool, though it has great search capabilities. Most of the tools I might never 'get', but when I explained what I wanted, the AI taught me how to use the tool to do it.

My experience in the corporate IS/IT sector tells me that those jobs are secure. We had some projects that were millions of lines of code and a staff of (guessing here, bad memory) 50 or more.

The coding part of the project's total manpower was about 20%. A lot more than that was spent on Analyses. Although that may seem like a good use of AI, it is, in my opinion, not going to work. So much of human communication is subtle things like facial expressions, raised eyebrows, body language, and tone. A (good) analyst is reading all those signals. Remember, the low-paid clerks are being interviewed by the high-paid IS/IT guy in order to replace his job with a computer. Even though it's unlikely to be true and the clerk will get a better job after training to work with the computer, at first, they don't believe it.

However, what if they could build a robot that can read human facial signals, tone and body language, etc. Now that could be a problem.

I am glad I am retired, I would not want to wrestle this beast, I think I am better but there is a little voice at the back of my head saying 'look out behind you'!

That would be due to it being one of the best at Arduino code, and dare I say most other languages too

I use these myself, under severe overwatch and instruction sets from myself.

This is where a whole new skill comes in. There is an entire skillset around learning to communicate ideas and intent across to an AI. I have not had to post code issues here very often since I started using AI, as 99% of the time it writes “perfect” code. Albeit it can write very succinct code that can be ultimately very hard for a human to understand.

And then where AI REALLY succeeds is documentation. I have found old code I wrote, couldn't remember what it was for. Feed it to Claude, it spits out a README that explains exactly what the code does, what modules/circuitry it runs on, and gives a pinout map to boot. Or, it can spit the identical code back out to me, fully commented.

If asked, it will also feed me a suggestions list on how to make the code better.

As a last note though, I want to be clear on something. A “noobie” should NEVER use AI. AI is a tool, not a replacement. Do NOT use AI, unless you could write it all by yourself.

2 Likes

I didn't know that about Claude. Who is behind that one?
EXCELLENT advice re 'noobie', but I fear they will do quite the opposite

Anthropic. If you pay for it, you can connect it to your Github, and it directly pulls the code, updates, adds, writes it, then pushes back to Github. It can run your code loacally and test it for you too.

They will and do.

I am not github trained, is that important?

You can use it without github, though github makes version control, rollbacks, and tracking everything so much easier. If you have Linux, you can install Claude into your CLI and it can basically use your computer as it desires - reviewing code, writing code, running code, talking to you, searching the web…

It’s surprisingly advanced.

I don;t know what is going on but the first link I clicked for it there was no free plan but the paid plans were not too bad, I think $99 per year, but I wanted to try for free so I googled claude free and got an option for free but the pro plan was $140 per MONTH.
What can you tell me, a link would be nice if it's a reasonable price for a retired poor hobbyist.

https://claude.ai/new

This is the official one. Be aware you only get a few messages per five hours on the free plan, and the agent I mentioned isn’t available, being https://claude.ai/code, which costs ~$35 AUD per month. Max plan | Claude

I have watched Spiess' video myself and I have a question: when he said "I asked for more debug messages and Claude implemented them, reviewed the output and corrected the code itself", how does one run MCU code on a computer?
Are there any emulators for AVR? ESP32?

A retired poor hobbyist, there’s 2 good options I have found, 1 is just use the chatbot claude.ai. On the free plan you can talk with it quite a lot. If you have a lot of interaction with it, it will make you take breaks of a couple hours at a time. By the time you talk to it that much you need a break anyway. I thought the term prompt engineering was funny at first, it’s a thing. People learn how to ask it questions properly, and that is prompt engineering. I don’t think there’s a lot to it, but seeing how other people chat with it makes me understand how people may need to study prompt engineering. I guess I’m good at it naturally or caught on quick. To get good results you need to be good at describing in plain language just like you’re talking to a person what it is you want. Lay out the requirements in detail and it will produce very good results. If you suck at communication, it will give you sucky results. Most people suck at communication (not you guys of course) so there is a field of study called prompt engineering. I’m sure people will say I oversimplify. Sorry about that.

Second option is install VS Code and connect it to Github for version control, and install the Arduino Community Edition extension and the Gemini Code Assist extension. Just as with claude.ai, you engineer your prompts and it will produce very good code. The difference with this one is it will go off and actually write code in the IDE and save the files. It is an agentic AI, which means it does stuff, not just talk with you. I recommend do not turn on the “agent” slider or the preview button, which puts it in a state that I have found to be over aggressive and weird. Just using it in regular mode is agentic. Create a new file in VS Code and tell it what to do and it will get busy.

1 Like

You explained it better than me.

THIS is what I find most interesting. Back in the 70s/80s, when I worked for a Dow top 5, I noticed that building systems was a series of what I called translations. This is just a specific kind of communication. User requirements to system specifications, system specifications to design documents, design documents to code.
A very few systems truthfully succeeded, and most failed to some degree. Of course, management put lipstick and rouge on the pigs and called them beauty queens.
We had a saying back then: when a system was finished, users would build a system of their own around the shiny new system so they could do their work. We always thought that was 'cute' and did not realize that was a HUGE clue that we, the systems guys and gals, had missed the mark.
If I could go back in time and had the skills, I bet I would find that the failing systems had lousy communications, especially or maybe only at the first 'translation'. If the foundation is lousy, the house will fall.
If AI can 'fix' that problem, then that could be a huge game changer.

Yes it can fix that. You only need the one set of requirements and they don’t need to be translated, and don’t need a specific style, they just need to be clear. Set up your VS Code and have Gemini Code Assist help you write your requirements doc for your program. Just plain English or whatever language you want to use, AI doesn’t care. Make it clear and list out the required features of the program. You can be specific and you can even include style guidance. If you want it to fashion delays done a certain way such as in the style

if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
//do stuff here
}

and don’t use delay() or other blocking code because you want the loop() to run all the way through hundreds or thousands of times per second, then make that a requirement. Or you can tell it use millis() instead of delay() as in examples found in Arduino for BlinkWithoutDelay. You can ask it imagine if you are a programmer and look over the requirements document, is there anything in there you would need clarifications for in order to make a good program?

When you get done writing the requirements, tell Gemini Code Assist you are a top-notch seasoned professional programmer, use this requirements doc as a prompt and create the program.

Um, a couple of misunderstandings there: translating is NOT what you think. We all spoke English; translating is converting user-speak (requirements) to systems analysis specs, etc.
These were corporate projects from 3 months to multi-year, with from 6 to 300 people, one time even more in multiple countries. All before github or any of the tools you take for granted today.

Maybe I wasn't clear, I am talking about. systems that run on one or more $5M main frames. The project life cycle is feasibility, analyses, design, code, test.
The first place I would use AI is the testing phase, that is something almost everyone was bad at myself included. Then AI could be a code helper. Maybe do design review?
Based on my experience with ChatGPT (paid version) I most definitely would not allow AI do feasibility, analyses or design other than design review.

you forgot at the end "work around quirks" and "throw away" :slight_smile:

Many projects with such a life cycle end up twice over budget, took twice as long as planned and were delivered ready to to address the issues users needed assistance with a few years before and now their issue is elsewhere.

I've seen that so many times !