ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > Living Room

AI Coding Assistants (Who uses them and which)

<< < (8/9) > >>

Shades:
You could watch a TV-series, called 'Beacon 23'. Which plays in distant future, where humankind uses manned beacons for interstellar travel. And you get a hint of what life is like in such a beacon., which belong to corporations that have AI on those beacons themselves, and tend to provide a personal AI to the person manning the beacon.

Might sound boring for a sci-fi series, but it really isn't. Quite a bit more serious than your movie idea. Which I think would go over well  :D

KynloStephen66515:
Thanks Kynlo. While I was adding these to my bookmarks, I decided to try out LobeChat's hosted version. It went something like this (highly paraphrased):


Q: Does the onboard LED of the Raspberry Pi Pico W support PWM to adjust its brightness?

A: Yes, it does.

Q: Can you show me some example code that will fade the LED?

A: This code will do that for you.

[ 15 minutes trying to get the code to work ]

Q: The code isn't working. What might be wrong?

A: Try these troubleshooting steps.

[ 15 minutes trying all the troubleshooting steps ]

Q: Are you absolutely sure the onboard LED supports PWM?

A: My apologies. The onboard LED does not support PWM.

Q: Can you show me example code to simulate PWM to adjust the LED's brightness in software rather than hardware?

A: This code will do that for you.

[ It works! ]

Pretty helpful when it doesn't lead you on a wild goose chase with wrong information.


I'm surprised there hasn't been a movie made yet about a group of people with a robot/AI companion who all end up stuck in a cavern and they ask the robot/AI
to help them find a way out and it unintentionally states incorrect information as fact and based on that information (and future queries to the robot/AI that don't challenge the initial assumption) the humans travel through a treacherous path where many people are injured or die until finally someone asks "Are you sure this is the best course of action?" and then the robot/AI says "My apologies. We can just take the ladder near where we started." ;D
-Deozaan (October 26, 2024, 05:55 PM)
--- End quote ---

What model did you use for this?

I'd highly suggest only using Claude-3.5-Sonnet-Latest, for coding-related work, as it's the only one that's actually any use.  GPT4o isn't terrible, but given that it has a knowledge cutoff in 2023, it has absolutely no idea about anything more recent.


This is the output I got using Claude (albeit, with a tuned system prompt for coding):

Yes, the Raspberry Pi Pico W's onboard LED (GPIO 25/"LED" pin) does support PWM! I'll show you both hardware PWM and software PWM approaches.

1. Hardware PWM Solution: Here's a complete example that fades the LED up and down using hardware PWM:


--- ---from machine import PWM, Pin
import time

# Setup the onboard LED with PWM
led_pwm = PWM(Pin("LED"))  # GPIO 25
led_pwm.freq(1000)  # Set PWM frequency to 1000Hz

def pulse_led():
    while True:
        # Fade in
        for duty in range(0, 65535, 1000):
            led_pwm.duty_u16(duty)
            time.sleep(0.01)
           
        # Fade out   
        for duty in range(65535, 0, -1000):
            led_pwm.duty_u16(duty)
            time.sleep(0.01)

try:
    pulse_led()
except:
    # Clean up PWM on exit
    led_pwm.deinit()

2. Software PWM Solution (if hardware PWM isn't working): This simulates PWM using software timing:


--- ---from machine import Pin
import time

led = Pin("LED", Pin.OUT)

def set_brightness(brightness):
    # brightness should be between 0 and 100
    cycle_time = 0.001  # 1ms cycle
    on_time = (brightness / 100.0) * cycle_time
    off_time = cycle_time - on_time
   
    led.value(1)
    time.sleep(on_time)
    led.value(0)
    time.sleep(off_time)

def pulse_led():
    while True:
        # Fade in
        for brightness in range(0, 101, 5):
            for _ in range(10):  # Multiple cycles per brightness level
                set_brightness(brightness)
       
        # Fade out
        for brightness in range(100, -1, -5):
            for _ in range(10):  # Multiple cycles per brightness level
                set_brightness(brightness)

try:
    pulse_led()
except:
    led.value(0)  # Turn off LED on exit

Key differences between the approaches:

Hardware PWM:

* More efficient
* Smoother fading
* No CPU overhead
* Uses dedicated hardware
Software PWM:

* More CPU intensive
* May show slight flickering
* Works on any GPIO pin
* Useful when hardware PWM isn't available

To run either example:


--- ---mpremote cp main.py :main.py

--- ---mpremote reset
The LED should start fading in and out in a continuous loop. The hardware PWM version will give you the smoothest results, but both approaches work to demonstrate LED brightness control.

Deozaan:
What model did you use for this?
-KynloStephen66515 (October 27, 2024, 08:20 AM)
--- End quote ---

When I created my account it asked me what I was interested in and I selected the option that appeared to be more about coding and development. It then suggested (and I accepted) a bunch of "assistants" which I assumed it would query all of or pick the best one for me based on my question. So I just started typing away (in the "Just Chat" section). :-[

Looking more into it, it seems to have created a variety of "assistants" for me on various topics but they are all set to use gpt-4o-mini, except for one which is set to use gpt-3.5-turbo-16k.

I'll try adjusting or creating one using Claude and see if that gives better results, but judging on your answer, it still gives you incorrect information. As far as I can tell the onboard LED of the Pico W does not actually support (hardware) PWM, because it's controlled by the WiFi module instead of the RP2040. But there's a big enough knowledge gap for me that I may be wrong about that. Maybe the fact that I'm using Arduino IDE (which I think is just C or C++) rather than MicroPython makes a difference in what hardware features the libraries I'm including use.

KynloStephen66515:
Raspberry Pi Pico W's onboard LED
-Deozaan (October 27, 2024, 03:32 PM)
--- End quote ---

Not to stray too far off-topic, but you seem to be correct, as per: https://forums.raspberrypi.com/viewtopic.php?t=358964 and https://forums.raspberrypi.com/viewtopic.php?t=336836

GrumpyCoder:
I've been using Codeium for quite some time now.
It can be used in the browser directly, as an extension for VSCode/VStudio, or through their own editor Windsurf.
Best of all, it's completely free. They do have paid subscriptions with more features, but I never felt that I needed to upgrade.

PS: I'm not affiliated to Codeium in any way.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version