Using AI to write code for me???
Discussion
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.
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.
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.
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 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.
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.
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
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.
I haven't tested (yet) whether Claude/ChatGPT/Copilot/whatever is any better at it.
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.
JFDII 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.
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.
.: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.
Thanks for that. I like the idea of getting it to do some functions initially to build confidence.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
Edited by Scarletpimpofnel on Wednesday 22 July 21:50
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.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.
About a month ago, I started using a money manager app from Google play (I know, spreadsheet can do all that blah blah blah).
It does what I want, apart from one notable exception (I cannot exclude specific accounts from calculations).
Yesterday, I started playing with Base44 and asked it to create a money manager app for Android. I told it that I wanted:
- multiple accounts, including credit cards
- UK based
- Able to select which accounts contribute to the total
With a few tweaks / refinements - I had a working app within 30 mins on the free plan. I then ran out of "credits" for the day but this morning, added some more features (recurring transactions, templates for expenses with pre-filled in fields etc).
Overall it's probably taken a couple of hours of tweaking, but the results are incredible - a fully functioning Android App doing exactly what I want. I did run out of free credit again this morning, but was having enough fun that I signed up for a single month at $20.
Curiously - when you then cancel your auto renewal it offers you a "Lite" plan for $9 a month which removes the daily limit I keep hitting and a couple of other things, which is tempting.
It makes the odd mistake (e.g. showing a pending recurring transaction in the total) but they're easily fixed.
I'm sure I'll sign up for a month a few times in the future when I want an app. Being able to tune it to behave exactly how you want is great.
It does what I want, apart from one notable exception (I cannot exclude specific accounts from calculations).
Yesterday, I started playing with Base44 and asked it to create a money manager app for Android. I told it that I wanted:
- multiple accounts, including credit cards
- UK based
- Able to select which accounts contribute to the total
With a few tweaks / refinements - I had a working app within 30 mins on the free plan. I then ran out of "credits" for the day but this morning, added some more features (recurring transactions, templates for expenses with pre-filled in fields etc).
Overall it's probably taken a couple of hours of tweaking, but the results are incredible - a fully functioning Android App doing exactly what I want. I did run out of free credit again this morning, but was having enough fun that I signed up for a single month at $20.
Curiously - when you then cancel your auto renewal it offers you a "Lite" plan for $9 a month which removes the daily limit I keep hitting and a couple of other things, which is tempting.
It makes the odd mistake (e.g. showing a pending recurring transaction in the total) but they're easily fixed.
I'm sure I'll sign up for a month a few times in the future when I want an app. Being able to tune it to behave exactly how you want is great.
The secret to using AI to do anything is having a test and verification loop - you need test inputs that lead to known outputs and you tell the AI to verify what it's created against that.
Otherwise, there will be hidden errors in what it generates and you won't know until it bites you.
Otherwise, there will be hidden errors in what it generates and you won't know until it bites you.
If you are specific about what code is needed and what it needs to do I've found it quite good.
I've been learning power BI for work over the last few months and the paid for co-pilot we're forced to use is very good at giving me the M-code for things and (when I prompt it to) teach me what the code is actually doing relevant to my task etc.
Have had it spit out huge volumes of python code which goes into the alteryx python tool for geo-spatial things too. I've known what I want to achieve but no idea how to ever do it but co-pilot did, and that was the code I blindly pasted in and hit run on (as it is low impact) and it worked fine 8 times out of 10, was astonishing to watch it go
If you knew what you were doing it could be very powerful. But you need to understand a bit of what it's doing I think. Makes for a more robust outcome that you can maintain and troubleshoot in the future
I've been learning power BI for work over the last few months and the paid for co-pilot we're forced to use is very good at giving me the M-code for things and (when I prompt it to) teach me what the code is actually doing relevant to my task etc.
Have had it spit out huge volumes of python code which goes into the alteryx python tool for geo-spatial things too. I've known what I want to achieve but no idea how to ever do it but co-pilot did, and that was the code I blindly pasted in and hit run on (as it is low impact) and it worked fine 8 times out of 10, was astonishing to watch it go
If you knew what you were doing it could be very powerful. But you need to understand a bit of what it's doing I think. Makes for a more robust outcome that you can maintain and troubleshoot in the future
I think my app is finished - but with the features / tweaks I kept adding, it used up 90% of the monthly credits for Starter subscription (plus two free days worth).
I'm very happy with the result, but I'm also aware that - code wise - it's a very simple app, so anything more complicated would need spreading over multiple months or a higher subscription.
I'm tempted to keep the starter subscription going - but I think it might be better that the next time I want to play around I'll simply pay for a month of Builder - which has the additional advantage of allowing you to download the code (my day job is software), and even publish the apps in Play Store.
I'm very happy with the result, but I'm also aware that - code wise - it's a very simple app, so anything more complicated would need spreading over multiple months or a higher subscription.
I'm tempted to keep the starter subscription going - but I think it might be better that the next time I want to play around I'll simply pay for a month of Builder - which has the additional advantage of allowing you to download the code (my day job is software), and even publish the apps in Play Store.
Edited by davek_964 on Friday 14th August 10:54
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


