I have another update on my experience with Copilot and ChatGPT; along with a couple of follow-up questions.
I have finally succeeded in recreating code for the clock that I should to build, one day. I used ChatGPT initially as it seemed to be working well. However, when I studied the code that it had created, it was full of pin conflicts and other problems. No matter how I rephrased my requirements, I could not prevent the conflicts. I then tried Copilot which, after a number of false starts and several hours work, produced working code. You need to be extremely clear with your instructions, yet not too rigorous; an odd requirement. When I was very prescriptive the code would not even compile. Allowing the software more flexibility gave better results.
However, I have a couple of questions.
Question 1
The set up uses a separate RTC to keep time and a LCD to display the time and day. I have buttons to advance and retard the time. Using these I can alter the time displayed on the LCD. I cannot work out, though, whether I need a specific “set” button for the time. Some clocks have them, whereas others do not.
Is a set button needed?
Question 2
The code also sends signals to various pins to flash LEDs via a transistor circuit. There are pins to flash LEDs: once a second, once a minute, once an hour and once a day. It flashes another LED once, twice, thrice or four times on the quarters; and another on the hour, once, twice, thrice or more depending upon the hour.
However, the code runs sequentially meaning the seconds LED stops flashing whilst the minute LED flashes; they both stop whilst the hour LED flashes and so on including when the quarters strike and the hours chime.
Is there a way to modify the code so that these events so that they do not interrupt each other? In time, the LEDs will be replaced with relays to drive a visual display. The pauses will affect the accuracy of the mechanics.
I can post examples of the code if it helps.
James.
Q1:
With four buttons you can have a menu structure that allows almost anything. Planning and programming the decision tree is quite complicated though.
Q2:
Yes. Have a single loop that cycles every second and controls all the LEDs. Within that loop have series of conditional statements that decide which LEDs to light and which ones to switch off. For example, the seconds LED might switch on if the number of seconds is even. You might have a series of counters that increment every loop, the minute counter would cause the minute LED to come on when it reaches 60, at which point it would be reset. (These are off the top of my head as I don’t have much time right now)