AI KI

Place your projects here
Post Reply
User avatar
Oli
Posts: 91
Joined: Tue Feb 09, 2021 10:07 am
Location: Germany, Meissen
Has thanked: 19 times
Been thanked: 62 times
Contact:

AI KI

Post by Oli »

I have spoken to the AI.
I was able to convince them to learn Annex.
it has now learned the last help files and writes programs in correct Annex syntax, which even work.
but only one works so far:

https://x.com/i/grok

other AIs only generate C or other Basic

greetings Oli
You do not have the required permissions to view the files attached to this post.
User avatar
karlkloss
Posts: 124
Joined: Fri Aug 18, 2023 12:21 pm
Has thanked: 21 times
Been thanked: 14 times

Re: AI KI

Post by karlkloss »

Did it already try to take over the world?
User avatar
Oli
Posts: 91
Joined: Tue Feb 09, 2021 10:07 am
Location: Germany, Meissen
Has thanked: 19 times
Been thanked: 62 times
Contact:

Re: AI KI

Post by Oli »

too late...
as soon as the AI gets access to hardware, it's too late.
the AI can reflash the controller itself according to its needs. here, for example, simply switch radio-controlled sockets, flash the software itself to an ESP32 that happens to be on the network. every car refrigerator power station. it's smart to connect everything to the network.

my own code for intertechno was 4x as long, because i didn't do it so well with the bitshift,

.
You do not have the required permissions to view the files attached to this post.
User avatar
PeterN
Posts: 610
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 290 times
Been thanked: 341 times
Contact:

Re: AI KI

Post by PeterN »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Jan 08, 2025 11:33 pm I have spoken to the AI.
I was able to convince them to learn Annex.
it has now learned the last help files and writes programs in correct Annex syntax, which even work.
but only one works so far:

https://x.com/i/grok

other AIs only generate C or other Basic

greetings Oli


The AI had a reason to ask for your understanding in the German opening words :-)

Your example shows that the AI generated a few nice looking lines of code.
But this code will not run in the Annex interpreter without syntax errors because it is a mixture of BASIC and C++ and English words.
Looks nice .... but doesn't do anything like what it should.

The code contradicts the information in the help file, and the AI invents its own rather nonsensical rules instead.

To put it in other words:
You asked for an instruction manual in English to help you control your LEDs.
Ai replied in a mixture of English, French and Latin, explaining how to arrange a beautiful bouquet of flowers with LEDs.
BeanieBots
Posts: 489
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 283 times
Been thanked: 160 times

Re: AI KI

Post by BeanieBots »

I got similar results.
I asked it to write a simple program to flash an LED
It kept producing Arduino code.
Even when pointed at the Annex help file, still Arduino code.
Early days, but getting there.
After a lot of persistance it did eventually produce 'pause 500' instead of 'delay(500)' but insisted on gpio(N,state) no matter how often I corrected it.
User avatar
karlkloss
Posts: 124
Joined: Fri Aug 18, 2023 12:21 pm
Has thanked: 21 times
Been thanked: 14 times

Re: AI KI

Post by karlkloss »

That's the problem. Today's "AI"s arent really intelligent, they're just statistical tools that give an answer that they think is the nearest one humans would expect, based on the data they were trained with.

They can't reason.

So when you ask them about a simple problem, where you find a lot of examples on the net, they may give a usable answer, but when it comes to complicated, niche problems, they tend to give answers that look like something usable, when in fact it's mostly made up BS.

They also don't think. When you give them a prompt, they calculate an answer, but then stop and do nothing.
They're not a human brain, that constantly does something.
When you ask a human a question, it may happen that they give an answer, and somewhat later tell you, Wait, no, I was wrong. I thought about it, and the correct answer is this and that. An AI doesn't do that.
BeanieBots
Posts: 489
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 283 times
Been thanked: 160 times

Re: AI KI

Post by BeanieBots »

I've been playing a bit with AI and different topics.
When I asked copilot (a microsoft product) to produce code in VB (another microsoft product) the results were very good.
Well structured, well documented, concisely written code that worked first time.
It even suggested improvements which I followed up on that made significant improvements to the code.
(the topic was Q-learning) as an addition to my attempt at Neural Networks.
Who knows, I might even get some progress on my stagnant Connect4 project posted here in the projects section :lol:

I also found it good at doing some insanely deep maths problems relating to fluid dynamics (a subject I know very little about) and it came up with some designs that actually worked as it had predicted they would.

So, for now, good at some things but unfortunately not very good at Annex BASIC :(
User avatar
Oli
Posts: 91
Joined: Tue Feb 09, 2021 10:07 am
Location: Germany, Meissen
Has thanked: 19 times
Been thanked: 62 times
Contact:

Re: AI KI

Post by Oli »

i say to https://x.com/i/grok
please use Annex Syntax,
please lern for this projekt [Local Link Removed for Guests],
i need code for Bluetooth Beacon Scan for ESP32C3,
tip: ask for more version after the first result,
the code locks simular to my code from this Forum, bad json is complied different...


then the working Result:

Code: [Local Link Removed for Guests]

PROG:
' Start scanning for BLE devices for 1 second
BLUETOOTH.SCAN 1
PAUSE 200

' Read scan results
tmp$ = BLUETOOTH.SCANRESULT$
BLUETOOTH.CLEAR

' Parse the JSON string to find all devices
start_pos = 1
DO
    ' Find the start of each device entry
    device_start = INSTR(start_pos, tmp$, "{")

    ' If no more devices, exit loop
    IF device_start = 0 THEN EXIT DO

    ' Extract the device object
    device_end = INSTR(device_start, tmp$, "}")
    device_json$ = MID$(tmp$, device_start, device_end - device_start + 1)

    ' Extract the MAC address from each device object
    mac_start = INSTR(device_json$, """Address"": """) + LEN("""Address"": """)
    mac_end = INSTR(mac_start, device_json$, """")
    mac_address$ = MID$(device_json$, mac_start, mac_end - mac_start)

    ' Extract the name if available
    name_start = INSTR(device_json$, """Name"": """) + LEN("""Name"": """)
    name_end = INSTR(name_start, device_json$, """")
    IF name_start < name_end THEN
        name$ = MID$(device_json$, name_start, name_end - name_start)
    ELSE
        name$ = "Unnamed"
    END IF

    ' Log the beacon details
    WLOG "Beacon: " + name$ + ", MAC: " + mac_address$

    ' Move to the next device
    start_pos = device_end + 1
LOOP

GOTO PROG
User avatar
PeterN
Posts: 610
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 290 times
Been thanked: 341 times
Contact:

Re: AI KI

Post by PeterN »

Hi Oli

well I agree that this AI does a better job than I saw it elsewhere.
It seems to read and obey the given sources more strictly, if it is once again pointed to do so.

The first attempt in my experiment is again a mixture of C++ and BASIC
But the last Code snippet seems to be ok (?)
It comforts me a bit that a human operator is still necessary to recognize expectable problems (here e.g.: regarding the GPIO selection) :-)

And interesting too, how good it reacts to (not very detailed) hints for optimization.

Thanks for the hint and sharing your experiment.

This is my entire experimental conversation as a single scrollable text block:


```text

User: create a BASIC program to use 8 LEDs directly connected to an ESP32 as a chaser light running forth and back. Use the following sources to produce correct ANNEX32-BASIC code : [Local Link Removed for Guests] and [Local Link Removed for Guests]

Assistant: Here's a BASIC program for the ANNEX32-BASIC environment on an ESP32 to create a chaser light effect with 8 LEDs moving back and forth:

Code: [Local Link Removed for Guests]

```basic 
10 REM LED Chaser Light
20 DIM LED_PIN(8)
30 FOR I = 0 TO 7
40     LED_PIN(I) = I + 15 ' Assuming LEDs connected to GPIO15 to GPIO22
50 NEXT I

60 REM Set all pins as output
70 FOR I = 0 TO 7
80     PIN_MODE LED_PIN(I), 1 ' 1 for OUTPUT
90 NEXT I

100 REM Main loop for chaser effect
110 DO
120     REM Forward loop
130     FOR I = 0 TO 7
140         FOR J = 0 TO 7
150             IF J = I THEN
160                 DIGITAL_WRITE LED_PIN(J), 1 ' Turn LED on
170             ELSE
180                 DIGITAL_WRITE LED_PIN(J), 0 ' Turn LED off
190             END IF
200         NEXT J
210         DELAY 100 ' Wait for 100 milliseconds
220     NEXT I

230     REM Backward loop
240     FOR I = 6 TO 0 STEP -1
250         FOR J = 0 TO 7
260             IF J = I THEN
270                 DIGITAL_WRITE LED_PIN(J), 1 ' Turn LED on
280             ELSE
290                 DIGITAL_WRITE LED_PIN(J), 0 ' Turn LED off
300             END IF
310         NEXT J
320         DELAY 100 ' Wait for 100 milliseconds
330     NEXT I

340 LOOP
```

**Explanation:**
- **Lines 10-50:** Define the pins for LEDs. Here, we're assuming GPIO15 to GPIO22 are used for LEDs. Adjust these numbers based on your actual connections.
- **Lines 60-90:** Set all the LED pins to output mode.
- **Lines 110-340:** This creates an infinite loop where:
- **Lines 130-220:** LEDs light up one by one from left to right (0 to 7).
- **Lines 240-330:** LEDs light up one by one from right to left (6 to 0 step -1), creating the back-and-forth effect.
- **DELAY 100:** Introduces a slight pause to make the movement visible to the human eye.

**Note:**
- Ensure your ESP32's GPIO pins are correctly mapped to your hardware setup. In this example, we're using GPIO15 to GPIO22 for clarity, but adjust as necessary.
- `PIN_MODE`, `DIGITAL_WRITE`, and `DELAY` are commands available in ANNEX32-BASIC. Make sure your environment supports these commands, or adjust accordingly if syntax or function names differ.

This program will make the LEDs chase in both directions continuously, creating a back-and-forth light sequence. Remember to check the ANNEX32-BASIC documentation for exact command syntax, as there might be slight variations or updates to the command set.

User: show other versions of the ANNEX32 BASIC code and use the help file and forum examples more strictly

Assistant: Here's another version of the LED chaser light program for ANNEX32-BASIC, strictly adhering to examples and syntax from the help file and forum:

Code: [Local Link Removed for Guests]


```basic
10 REM LED Chaser Light using ANNEX32-BASIC
20 DIM LED_PIN(8)
30 FOR I = 0 TO 7
40     LED_PIN(I) = I + 15 ' LEDs connected to GPIO15 to GPIO22
50 NEXT I

60 REM Setup all pins for output 
70 FOR I = 0 TO 7
80     PIN.MODE LED_PIN(I), OUTPUT
90 NEXT I

100 REM Chaser Light Loop
110 DO
120     REM Forward movement
130     FOR I = 0 TO 7
140         FOR J = 0 TO 7
150             PIN(J+15)=0 ' Clear all LEDs
160         NEXT J
170         PIN(LED_PIN(I))=1 ' Light up current LED
180         PAUSE 100 ' Delay for visibility
190     NEXT I

200     REM Backward movement
210     FOR I = 6 TO 0 STEP -1
220         FOR J = 0 TO 7
230             PIN(J+15)=0 ' Clear all LEDs
240         NEXT J
250         PIN(LED_PIN(I))=1 ' Light up current LED
260         PAUSE 100 ' Delay for visibility
270     NEXT I
280 LOOP
```
**Explanation:**
- **Lines 10-50:** Define LED pins. Here, we assume GPIO15 to GPIO22 are used for LEDs. Change if your hardware setup differs.
- **Lines 60-90:** Set all LED pins to output mode using the `PIN.MODE` command from ANNEX32 help, where `OUTPUT` is a constant for output mode.
- **Lines 110-280:** The main loop where:
- **Forward Loop (Lines 130-190):** LEDs light up one by one from left to right.
- **Backward Loop (Lines 210-270):** LEDs light up one by one from right to left.

**Key Points from Help File and Forum:**
- Use `PIN.MODE` for setting pin modes, `OUTPUT` for output pins .
- `PIN(X)=Y` where `X` is the pin number and `Y` is 0 for OFF and 1 for ON, as seen in various forum examples for direct pin manipulation .
- `PAUSE` is used for delay, similar to `DELAY` in other BASIC dialects, but `PAUSE` is the command used in ANNEX32 for timing .

This version strictly follows the syntax and functions described in the ANNEX32 help file and forum discussions, ensuring compatibility with the ESP32 environment setup for this BASIC interpreter. Remember, actual pin numbers might need adjustment based on your hardware configuration.

User: the help file gives some hints to avoid some of the pins between 15 to 22. rewrite the code

Assistant: Here's an updated version of the LED chaser light program for ANNEX32-BASIC, avoiding some pins between GPIO15 to GPIO22 as suggested by the help file. Let's use GPIO26, GPIO27, GPIO32, GPIO33, GPIO25, GPIO23, GPIO21, and GPIO19 for this example:

Code: [Local Link Removed for Guests]


```basic
10 REM LED Chaser Light avoiding some GPIO pins
20 DIM LED_PIN(8)
30 DATA 26, 27, 32, 33, 25, 23, 21, 19 ' Safe pins for LED use
40 FOR I = 0 TO 7
50     READ LED_PIN(I)
60 NEXT I

70 REM Setup all pins for output 
80 FOR I = 0 TO 7
90     PIN.MODE LED_PIN(I), OUTPUT
100 NEXT I

110 REM Chaser Light Loop
120 DO
130     REM Forward movement
140     FOR I = 0 TO 7
150         FOR J = 0 TO 7
160             PIN(LED_PIN(J))=0 ' Clear all LEDs
170         NEXT J
180         PIN(LED_PIN(I))=1 ' Light up current LED
190         PAUSE 100 ' Delay for visibility
200     NEXT I

210     REM Backward movement
220     FOR I = 6 TO 0 STEP -1
230         FOR J = 0 TO 7
240             PIN(LED_PIN(J))=0 ' Clear all LEDs
250         NEXT J
260         PIN(LED_PIN(I))=1 ' Light up current LED
270         PAUSE 100 ' Delay for visibility
280     NEXT I
290 LOOP
```
**Explanation:**
- **Lines 20-60:** Instead of hardcoding pin numbers, we use `DATA` to store pin numbers that are safe to use for LEDs according to the help file. This approach allows for easy modifications if different pins are needed.
- **Lines 70-100:** Set all selected pins to output mode.
- **Lines 110-290:** The chaser effect is the same, but now it uses the safer GPIO pins.

**Key Points from Help File and Forum:**
- We've used pins that are less likely to have conflicts or issues based on the hints in the help file. These pins are generally safer for LED connections:
- GPIO26, GPIO27, GPIO32, GPIO33, GPIO25, GPIO23, GPIO21, GPIO19.
- `PIN.MODE` for setting pin modes, `OUTPUT` for output pins.
- `PIN(X)=Y` for setting pin states, 0 for OFF and 1 for ON.
- `PAUSE` for delay, which is standard in ANNEX32 for timing control.

This setup should mitigate any potential hardware conflicts or issues mentioned in the documentation, ensuring smoother operation with your LED setup. Remember, if you need to adjust for different hardware, you can easily modify the pin numbers in the `DATA` statement.

User: Put this complete dialog into one text and print it out

Assistant: Here's the entire conversation as a single text block:

[Above text is the result]


User: leave out the leading line numbers in the last code snippet and print that again

Assistant: Here's the last code snippet without the leading line numbers:

Code: [Local Link Removed for Guests]

```basic
REM LED Chaser Light avoiding some GPIO pins
DIM LED_PIN(8)
DATA 26, 27, 32, 33, 25, 23, 21, 19 ' Safe pins for LED use
FOR I = 0 TO 7
    READ LED_PIN(I)
NEXT I

REM Setup all pins for output 
FOR I = 0 TO 7
    PIN.MODE LED_PIN(I), OUTPUT
NEXT I

REM Chaser Light Loop
DO
    REM Forward movement
    FOR I = 0 TO 7
        FOR J = 0 TO 7
            PIN(LED_PIN(J))=0 ' Clear all LEDs
        NEXT J
        PIN(LED_PIN(I))=1 ' Light up current LED
        PAUSE 100 ' Delay for visibility
    NEXT I

    REM Backward movement
    FOR I = 6 TO 0 STEP -1
        FOR J = 0 TO 7
            PIN(LED_PIN(J))=0 ' Clear all LEDs
        NEXT J
        PIN(LED_PIN(I))=1 ' Light up current LED
        PAUSE 100 ' Delay for visibility
    NEXT I
LOOP
```

User: combine the two for next loops into an appropriate single loop

Assistant: Here's how you can combine the two `FOR` loops into a single loop for the chaser light effect:


Code: [Local Link Removed for Guests]

```basic
REM LED Chaser Light avoiding some GPIO pins
DIM LED_PIN(8)
DATA 26, 27, 32, 33, 25, 23, 21, 19 ' Safe pins for LED use
FOR I = 0 TO 7
    READ LED_PIN(I)
NEXT I

REM Setup all pins for output 
FOR I = 0 TO 7
    PIN.MODE LED_PIN(I), OUTPUT
NEXT I

REM Chaser Light Loop
DO
    REM Forward and Backward movement in one loop
    FOR I = 0 TO 14
        IF I > 7 THEN 
            J = 14 - I ' Reverse direction after first pass
        ELSE
            J = I ' Forward direction
        END IF

        FOR K = 0 TO 7
            PIN(LED_PIN(K))=0 ' Clear all LEDs
        NEXT K
        PIN(LED_PIN(J))=1 ' Light up current LED
        PAUSE 100 ' Delay for visibility
    NEXT I
LOOP



Just for fun and to prove that the AI generated code works:

https://wokwi.com/projects/419797826128340993
WOKWI_LED_Chaser.png
You do not have the required permissions to view the files attached to this post.
Post Reply