You should make a fundamental decision:
either ask chatGPT so many times until the code works
or
learning programming yourself with the support of the arduino-forum
This is the reason why:
Analyzing and understanding AI code as a human is significantly more difficult than code written by humans.
This means you have to make the users five to ten times more work to understand the code!
And no PERSON does that!"
It is critical to write code in a way that people can understand, so we can find and fix bugs, and maintain and update code.
This will no longer be necessary when machines can do this reliably - which is probably the most difficult task!!! -
This requires very, very precise specifications that are clear, complete and unambiguous!
AI code structure requires much more “abstract thinking.” Maybe it's because the whole task is "abstract" for an AI without access to human reality...
So please be kind to those members who think their time is too valuable to waste on temporary improvements that will be gradually undone by an AI that has no real understanding of a specific task.
Either you switch to consistent programming. You as a human being learn programming.
And then you will get hundreds of questions answered here
or
you stick consistently with AI.
This AI is supposedly sooooooooo intelligent.
Keep writing prompts to the AI until the code works the way you want.
So make your decision:
100% chatGPT-code
or
100% human written code
best regards Stefan