Generating code with ChatGPT

Buzby

Senior Member
This was ChatGPT last year ....

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 !
 

Gramps

Senior Member
We don't have proper 'general use' robots yet. The hardware is ready ( Boston Dynamics, etc ), but they still need brains. AI will provide them
The problem I see with general use robots is not brains but batteries!
Boston Dynamics posted a 37 second demo of their new robot. Very impressive, but I think the battery would only last 60 seconds hence a very short video.
 

papaof2

Senior Member
Limited battery capacity and life were the reasons some early satellites used nuclear power cells, with the heat of nuclear decomposition warming thermocouples to provide long-term power. There were some near-panic responses when the launches of those sats failed and they had to find and recover the possibly radioactive bits and pieces.
Don't know that we'll see small nuclear power packs offered as "lifetime" batteries, complete with the assorted nuclear warning labels and seals and the need for attending and successfully passing a "Nuclear Battery Maintenance Course". Too many curious folks that would want to see "What's inside?" and let out the magic smoke and some of the not-so-magic radiation :-(
LTO batteries do have potential to improve on their current cycle life of 10,000 charge discharge cycles (27+ years at one cycle/day) but there are still the weight and size considerations. The hype I've seen on sodium ion batteries claims they are smaller and lighter than lithium batteries for the same power. Until I've seen tests by a known independent lab - or I can get "hands on" to do my own testing, I'll take their claims with a grain of salt ;-) Last I checked, one of the sodium ion battery companies wanted $150 just for the shipping of a few 18650 size cells - not something this old retired guy can justify for curiosity.
I saw one of the early "mule" robots which used an internal combustion engine for power. Using fuel injection resolves the problems of fuel flow in a machine which can get more than 90 degrees from the horizontal and the problems of managing oil flow to and from the oil sump (or its equivalent) were solved long ago for the engines used in acrobatic and military fighter aircraft so that could be the power source of a robot in a breathable atmosphere. But how much fuel can it carry and how does that affect its ability to do what is needed and how long can it run? And how would the sloshing of fuel in a partly empty tank affect its ability to position itself?
I'm the pessimist every designer needs looking over his/her shoulder ;-)
 
Top