Buzby
Senior Member
This was ChatGPT last year ....
This is ChatGPT this year ...
It's getting better !
I'm not sure what to make of this code generated by ChatGPT .....
' PICAXE code for a "Knight Rider" display
symbol leds = b.0 ' define the LEDs as b.0
main:
for delay = 1 to 20 ' loop through the delay
for led = 0 to 7 ' loop through the LEDs
shiftin leds, leds, right ' shift the LEDs to the right
high leds.0 ' turn on the first LED
pause 50 ' delay for 50ms
next led
next delay
goto main ' loop the program
In this code, the LEDs are connected to pin B.0 of the PICAXE microcontroller. The "main" loop starts by iterating through a delay loop and then through the LEDs. Within the inner loop, the LEDs are shifted to the right using the "shiftin" command, and the first LED is turned on using the "high" command. Finally, a pause of 50 milliseconds is used to create a delay between each LED being lit.
This is ChatGPT this year ...
Code:
#picaxe 08m2
' Define the pins for the LEDs
symbol LED1 = C.1
symbol LED2 = C.2
symbol LED3 = C.3
symbol LED4 = C.4
symbol LED5 = C.5
symbol LED6 = C.6
symbol LED7 = C.7
symbol LED8 = C.8
' Define the delay time between LED changes
symbol delayTime = 100
main:
' Move LEDs from left to right
high LED1
pause delayTime
low LED1
high LED2
pause delayTime
low LED2
high LED3
pause delayTime
low LED3
high LED4
pause delayTime
low LED4
high LED5
pause delayTime
low LED5
high LED6
pause delayTime
low LED6
high LED7
pause delayTime
low LED7
high LED8
pause delayTime
low LED8
' Move LEDs from right to left
high LED7
pause delayTime
low LED7
high LED6
pause delayTime
low LED6
high LED5
pause delayTime
low LED5
high LED4
pause delayTime
low LED4
high LED3
pause delayTime
low LED3
high LED2
pause delayTime
low LED2
' Repeat the sequence
goto main
It's getting better !