Using AI to write code for me???
Using AI to write code for me???
Author
Discussion

Scarletpimpofnel

Original Poster:

1,452 posts

45 months

Monday 20th July
quotequote all
I've just been reading this thread - https://www.pistonheads.com/gassing/topic.asp?h=0&... - and realised maybe I should now lean more heavily on AI.

I like making electronics projects with a Raspberry Pi controller using MicroPython code. Whilst I have some design documentation (in the loosest sense!) for the code such as "If GPIO 1 goes high then light up LED 3 and make GPIO 5 high to driver the motor M1" etc.

Questions:

1 - What is the input to AI for it to be able to spit me out some woreking code? Is it a whole list of statements like the above or are their specific design documentation standards that need to be created?
2 - How does AI deal with real world stuff like when a user presses a switch to trigger GPIO 1 to high, in the real world there can be switch bounce etc that the software needs to handle?
3 - Are some AI better than others at this kind of stuff? Do those in the know about AI have a list of what AI to use for what type of task?
4 - How do I know what is available via paid for features vs free features for each AI?

Many thanks.

Hedobot

781 posts

176 months

Monday 20th July
quotequote all
Why dont you just ask Claude.

Tell it your situation and see what the response is.

Everyone has to start somewhere


JoshSm

4,523 posts

64 months

Monday 20th July
quotequote all
Depends on all sorts but if you want you can just vibe code it and put in your requirements and go back and forth with it.

If you really want to as a first cut you can just put Google search into AI mode and use that, it's a free unlimited way to get Gemini Flash 3.5 even if it is a bit functionally limited and can't create files etc. Its fast and has huge context size. Good as a starting point for playing with AI and more up to date with data than some options.

Google will also spin up a free hosted dev environment if you wanted a bit more, though that will have usage rate limits.

For playing about you don't need full agentic tooling, or rules, or prompt engineering. For simple stuff you also won't need any of the more code specific models.

Also don't trust anything it does. Check it. It's a savant not a genius and will do all sorts of stupid stuff given a chance.

I'm just playing around with my latest setup with the proper integrated agentic tools and a huge, very code capable model (on an equally huge server stack) and it's still a long way from perfect (and burning many many millions of tokens) and for very casual simple stuff I'd probably just lean on something like Gemini as being a quick free way to get a result.

It might be imperfect but it's free and it's fast for a response.

Just don't put anything private into it.

Mr Penguin

4,512 posts

66 months

Monday 20th July
quotequote all
If you are going to use something like claude code or open code make sure you use git for version control before everything goes wrong.

JoshSm

4,523 posts

64 months

Monday 20th July
quotequote all
Mr Penguin said:
If you are going to use something like claude code or open code make sure you use git for version control because everything will go wrong.
EFA. Though the automatic shadow commits stuff can be quite handy.

But the tools are very much capable of ruining stuff so always have a backup and don't point them at anything that matters.

Scarletpimpofnel

Original Poster:

1,452 posts

45 months

Tuesday 21st July
quotequote all
Thanks for the suggestions, I will have a play around with the tools suggested.

Dave Hedgehog

16,240 posts

231 months

Tuesday 21st July
quotequote all
i have been using gemini to write power shell and api scripts, i dont do it very often so its way faster than i am lol

.:ian:.

2,953 posts

230 months

Wednesday 22nd July
quotequote all
If you know exactly what you want the code to do, just feed all these into the prompt. You may find it does stuff thats not specified, sometimes good, sometimes bad.
Or if you know roughly what you are wanting to do, get it to write some functions around this, ie, give me some functions to accept debounced input on a gpio pin and pwm output using micropython on an xxx device, or whatever.

I would recommend using vscode and adding in either the github chat or claude agents. This then gives context aware coding assists, it will start to give you autocomplete prompts based on the code you have and what you type and will also correct your code.

This also comes with a gazillion plugins including stuff like platformio to build and push to arduino type devices.

Most of the ai agents give a certain amount of credits per day without paying, the more complex tasks you give it the faster you chew through these, but its quite possible to develop code without paying. You can also choose less complex models that consume the credits more slowly, these work ok for simple tasks.

Edited by .:ian:. on Wednesday 22 July 08:24

ajprice

32,955 posts

223 months

Wednesday 22nd July
quotequote all
It's a bit different to the OP as it isn't hardware programming or functions etc, but I have used Gemini to build a HTML/CSS email template with various column layouts that's responsive to screen sizes and to work across email clients (Outlook email on PC is a known pain in the arse for getting things to display properly). With a bit of tweaking of the widths to make things reflow properly, it worked pretty well.

I haven't tested (yet) whether Claude/ChatGPT/Copilot/whatever is any better at it.

48k

17,130 posts

175 months

Wednesday 22nd July
quotequote all
Scarletpimpofnel said:
I've just been reading this thread - https://www.pistonheads.com/gassing/topic.asp?h=0&... - and realised maybe I should now lean more heavily on AI.

I like making electronics projects with a Raspberry Pi controller using MicroPython code. Whilst I have some design documentation (in the loosest sense!) for the code such as "If GPIO 1 goes high then light up LED 3 and make GPIO 5 high to driver the motor M1" etc.

Questions:

1 - What is the input to AI for it to be able to spit me out some woreking code? Is it a whole list of statements like the above or are their specific design documentation standards that need to be created?
2 - How does AI deal with real world stuff like when a user presses a switch to trigger GPIO 1 to high, in the real world there can be switch bounce etc that the software needs to handle?
3 - Are some AI better than others at this kind of stuff? Do those in the know about AI have a list of what AI to use for what type of task?
4 - How do I know what is available via paid for features vs free features for each AI?

Many thanks.
JFDI

Start with Claude with the Sonnet 5 LLM for example and just tell it what you've said above eg "Generate the MicroPython code for the scenario that when GPIO 1 goes high then light up LED 3 and make GPIO 5 high to driver the motor M1. Make sure the code is robust to cope with possible switch bounce "

See if you agree with what it generates. If it needs refining, tell it. If you run out of credits buy some more. If the Sonnet 5 isn't fast enough or high quality enough, bump up to Opus 4.8 for example.

It really is a case of just getting stuck in, trying some things and seeing what gives you the best result.

I haven't written a line of code for about 3 months now. We even use LLMs to generate the requirements. It's not perfect but we improve with every iteration and it will get you 80-90% of the way there for little effort.

Scarletpimpofnel

Original Poster:

1,452 posts

45 months

Wednesday 22nd July
quotequote all
.:ian:. said:
If you know exactly what you want the code to do, just feed all these into the prompt. You may find it does stuff thats not specified, sometimes good, sometimes bad.
Or if you know roughly what you are wanting to do, get it to write some functions around this, ie, give me some functions to accept debounced input on a gpio pin and pwm output using micropython on an xxx device, or whatever.

I would recommend using vscode and adding in either the github chat or claude agents. This then gives context aware coding assists, it will start to give you autocomplete prompts based on the code you have and what you type and will also correct your code.

This also comes with a gazillion plugins including stuff like platformio to build and push to arduino type devices.

Most of the ai agents give a certain amount of credits per day without paying, the more complex tasks you give it the faster you chew through these, but its quite possible to develop code without paying. You can also choose less complex models that consume the credits more slowly, these work ok for simple tasks.

Edited by .:ian:. on Wednesday 22 July 08:24
Thanks for that. I like the idea of getting it to do some functions initially to build confidence.


Edited by Scarletpimpofnel on Wednesday 22 July 21:50

Scarletpimpofnel

Original Poster:

1,452 posts

45 months

Wednesday 22nd July
quotequote all
48k said:
JFDI

Start with Claude with the Sonnet 5 LLM for example and just tell it what you've said above eg "Generate the MicroPython code for the scenario that when GPIO 1 goes high then light up LED 3 and make GPIO 5 high to driver the motor M1. Make sure the code is robust to cope with possible switch bounce "

See if you agree with what it generates. If it needs refining, tell it. If you run out of credits buy some more. If the Sonnet 5 isn't fast enough or high quality enough, bump up to Opus 4.8 for example.

It really is a case of just getting stuck in, trying some things and seeing what gives you the best result.

I haven't written a line of code for about 3 months now. We even use LLMs to generate the requirements. It's not perfect but we improve with every iteration and it will get you 80-90% of the way there for little effort.
Thanks for the specifics. As you and others say I should just give it a go.