Tips for using ChatGPT to create code

I’ve written a few lines of code with ChatGPT now. Here are my tips.

  • Start with the most detail about the problem that you can. I’ve actually found that this is a great way to solve a problem whether you use ChatGPT or not - because it forces you to think hard about what you want it to make.

  • Don’t let ChatGPT add complication. It frequently suggests writing more code (for example processing the output of a method rather than changing what the method does).

  • Show ChatGPT the exact error that you got by pasting it into the conversation.

  • Ask ChatGPT to write your documentation too. If you ask it specifically, it will generate markdown files that you can download straight into your project. This works really well. Explain what kind of documentation you want, and the audience it is for.

  • Make a ChatGPT project and upload the source code into the project once you’ve got it mostly working. Then you can refer back to it directly later. Add documents too, especially ones that ChatGPT has written for you that need to be updated as you add functionality.

  • Try very hard not to let ChatGPT rewrite you entire program. When it does this the names of variables may change (filename will become file or name) and changes that you specifically requested earlier may well be omitted. Instead, ask for a set of step-by-step changes and additions that you can work through with it. This helps you build understanding of what ChatGPT is making for you.

  • Tell ChatGPT which bits you want to make first, and just make those. Then put the partially completed files in the project (see above) for it to work on.

  • If it does something that feels wrong, call it out. Best case you’ll get a good explanation of why it is working that way. Worst case you’ll find it has missed something. Which leads to….

  • Don’t assume that the emphatic way that it explains things means it knows what it’s doing. I’ve caught it making the most amazing howlers and heading off in really strange directions.

  • Don’t get upset when you are debugging code that it has written and it starts referring to the code as yours…..

Apple TV Foundation has suddenly got good

When Apple announced that they were making a TV series based on the Isaac Asimov Foundation books I was very pleased. I was less pleased when I actually watched it though, as it seemed ponderous, very full of itself and not that tied into the books I remembered enjoying. The second season was a bit better, although it still seemed to get bogged down with digressions I could do without. But the third season is a stormer. Fast moving action, a terrifyingly convincing baddie and some nice takes on the third volume of the series make it well worth a look.

Christmas Hardware Meetup

Underneath the picture is a breadboard with a PICO and a very old led plugged into it.

We had a select gathering at the Hardware Meetup tonight, but it was no less fun. There were a few entries into the “Christmas Lights” competition. I think the best lights came from Ian, in the form of the above, which not only involved considerable reindeer research, but also proper operation of a hole punch. Ross had brought a set of led panels from his amazing self-playing piano project and spent a while getting AI to develop a nice range of displays.

Animated coloured raindrops version 1

What you get if the AI doesn’t know exactly how your leds are wired.

Lots of fun, plenty of tech talk and even a chocolate or two. We’ll not be having a Meetup in two weeks on 24th December, what with it being Christmas Eve. Wonderful though meetups are, it is very likely that folks will have better things to do at that time. At least, I really hope they do. The next meetup will be on 7th January in 2026.

Hardware Meetup Wednesday 10th December

We’re having a Hardware Meetup in Hull Makerspace (top floor of Hull Central Library) starting at 5:00pm on Wednesday evening (10th December). You can arrive later if you like, but don’t arrive after 7:00pm because that’s when library shuts and we all go for dinner.

There’s a prize for whoever brings along the best Christmas Lights display. And everyone gets a mince pie and a chocolate. Please note that I’m not just doing this because I’ve found a great long string of neopixels. Oh no.

Printing Slow

..now with the words “half” and “Quarter”

I’ve been printing wordsearch clocks again. As you do. The first few prints were spectacularly unsuccessful, which was a surprise as my Bambu printer is usually super reliable. The problem was that the first layer that is printed is the white letters. These are very thin and I’ve always found that white filament tends to not stick as well as other colours. The result was a couple of very messy prints that I had to abandon. So, I tried slowing things down a bit.

This is the print speed menu in Bambu studio. You can change printing speed by height, so that the first few layers of a print can be printed very slowly giving the filament time to stick to the bed. I just print the first 4mm of the model at the low speed, but because this is one of the more complicated bits it added over an hour to the print time. But it also worked, which is nice. So now I can make white and black and black and white wordsearches.

Cleaning Battery Connections

I don’t know why I’m giving out camera repair tips. After all, the camera I’m mending is still not working properly. I’ve narrowed the problem down to one of the five transistors it contains, or perhaps one of the eight switches. Time will tell.

Anyhoo, if you have anything which contains a hard to access battery connection (perhaps at the bottom of a battery holder) you just Blu-tak a small piece of sandpaper to the end of a battery and then push the battery into the holder and rotate it a bit to clean off the connections. Works a treat (but will not fix any other electrical problems that you might have).

Blu-tak is actually really useful for mending stuff. You can use it to hold things on the bench, stick screws to the end of the screwdriver for tricky to access fixings, and also hold things in place while you assemble them.

Schrodinger's Revenge

Yesterday I was waiting for a battery to arrive so that I could discover whether I had a working camera (yay!) or a broken one (boo!). Of course, just because there are two outcomes doesn’t make them both equally likely, so I should have been prepared for brokenness. Which is what I got. Wah. So it was off with the top and…

It’s probably one of these wires…

A bit of experimentation with a multi-meter left me thinking that no power was getting to the system.

…or more likely this one.

One problem with old cameras is that chemicals leak out of the battery and corrode connections, which is what has happened here. So all I have to do is find the battery terminal and solder this wire back on. Or, replace the wire completely - which is what I ended up doing. So now, with the battery check light showing a happy green, I’d fixed the camera, right?

Wrong. The metering was all broken and the shutter didn’t open and close how it should. Turns out that my camera has succumbed to “The Pad of Death”. This is a thing with Yashica Electro 35 cameras. The shutter mechanism uses a tiny foam pad to transfer movement from one lever to another. But, plastic foam being what it is, after a while it turns to dust. No pad, no movement, broken camera.

There should be a foam pad where that pink yuccky stuff is

I had great fun fixing this. If by “great fun” you mean “nearly went insane rolling up small pads of tape and then trying to fit them into the slot between the two parts”. If it breaks again the camera will end up being a “display piece”. Or going on eBay as “sold for parts”.

Newly fitted pad. I hope the glue holds…

Anyhoo, I prevailed and now the meter is doing an impression of something that might be working. I’ll to some proper testing tomorrow, for now I’m happy that I get longer clicks with darker subjects. To be honest (why on earth to people say that - it’s like saying “I was thinking of telling you a lie, but I’ve changed my mind”) I don’t mind if the camera is not quite right yet. I’ve quite enjoyed fiddling with it - pad of death not withstanding - and I’ve gained a lot of respect for the people who designed and made this marvel of mechanics and early solid state electronics. I’m sure they didn’t expect folks to still be trying to use them 50 years after manufacture. It’s a tribute to them that they still mostly work.

Making Stuff Tech Session

I used the converted polaroid camera to take some audience pictures but the ambient light was too strong, so we got a lot of blur. I also added a red cast which you can just about see.

We had a lot of fun at the Tech Session tonight. Rory did a splendid talk on testing, which put software testing into a properly useful context, and then I talked for 45 minutes on the joy of making stuff and what I’ve been up to lately.

For anyone who wants to know what I was on about, I’ll record a screencast (with all of the demos) later this week. You can find out about upcoming Tech Sessions here.

In the Money?

I got a strange email this evening from a bunch of lawyers. It’s about the Anthropic Copyright Settlement. This is a class action brought on behalf of authors whose work allegedly appeared in a couple of allegedly pirate datasets that were allegedly used by Anthropic to train their AI systems. Allegedly. Anyhoo, I searched their database and 7 of my books were identified…

The settlement amount was 1.5 Billion dollars, but individual authors only get a tiny percentage of this. It’s nice to see some action being taken on behalf of creatives who have had their work used in this way but I reckon we still have a long way to go. Or at least, we should have. Now I get to fill in a form and wait until the end of April next year for the next phase of the process. I just hope I get enough to buy a camera…..

Colour Film Processing Fun

If you are wondering what is special about the picture above, its that I actually developed it myself. I’ve done a lot of black and white processing but I’ve always avoided colour because it just sounds too scary. But now you can get chemicals which only need two baths. This makes working with colour very like working with black and white, where you usually need dip the film in developer and fixer.

The only other problem with colour processing is that you need to keep the chemicals at a specific temperature; in our case 35 degrees centigrade. We did this by using a new fangled cooking tool called a “sous vide” which heats and circulates water around a bath we made from a plastic box. All we had to do was drop the bottles of developer and “blix” (bleach and fixer) into the bath and leave them there for a while, and then keep the developing tank in the bath while the film was being processed.

The whole thing went very well; once we’d mixed up the chemicals which took a little while. In all we developed four films. The chemicals should be good for another 8, and we might be able to develop even more if we increase the development time still further. I can’t really tell the difference between our negatives and ones from “proper” film processing places. By doing four films we’ve kind of broken even on the cost of the chemicals against sending the fillm away, the next few should see us moving into proper savings. Great fun. Just remember to wear gloves and work in a well-ventilated area.

Birmingham Comicon

You will practice your saxophone

We went to Birmingham Comicon today. It was great fun. The only thing I bought at the show was a year’s supply of saxophone lessons, and they weren’t actually on sale there, that was just a subscription I’d forgot to cancel that automatically renewed itself while I was in Birmingham. I hate it when they do that with no warning. But some good will come of this. I’m going to start practicing the saxophone again…

I took the big heavy camera too with a huge lens too. This proved very bad at getting focus, but I did get a few shots.

Hardware Meetup with lots of Python

Please note that the time is not six past sixteen. And always wear shoes.

We had a very pleasant evening at the Hardware Meetup tonight. I was showing off the Connected Little Boxes Micro Python framework which is powering a couple of clocks that I’ve made. They worked great right up to the point where the input parser broke. Oh well.

Then it was off for dinner, which was great. Conversation turned to a study which has discovered that the brain has five ‘eras’ with one (a precipitous decline in the amount of “white matter” - whatever that means) starting at around my age. Then, when I got back to my car I discovered that I’d left my backpack in the restaurant. Perhaps the study is onto something….

Significant Other Charms

These are the finished versions and they’ve printed quite well. The idea is that you have one, and you give your significant other, er, the other. Then, when you meet up you can fit them together (they do fit rather well). Each pair is completely unique (unless you print lots of them I suppose) and symbolises the uniqueness of whatever you think is unique about whatever your relationship is. Oh the romance of it all. I’m putting together some examples of writing Python code inside the FreeCAD design tool, and the charms are one of them. Another is my “Little City”.

Not bad for around 100 lines of code. The examples will all be going on GitHub soon.