Anyone using ChatGPT to code/debug?

This forum is for anything not Reason related, if you just want to talk about other stuff. Please keep it friendly!
Post Reply
User avatar
Re8et
Competition Winner
Posts: 1514
Joined: 14 Nov 2016

29 Apr 2023

I just learned ChatGPT can translates prompts to useful code in Arduino, and Micropython for the Raspberry Pi Pico... I haven't yet started, but this is gonna be huge...
Here is an example:

Prompt:
Create a Code a simple saw wave synthesizer in micro python


ChatGPT:
Sure, here's an example code for a simple saw wave synthesizer in MicroPython:

python
Copy code
import math
import pyb

# Define the pin for the speaker output
SPEAKER_PIN = pyb.Pin("X1", pyb.Pin.OUT_PP)

# Define the frequency and duration of the saw wave
FREQUENCY = 440 # Hz
DURATION = 1000 # ms

# Calculate the number of samples to generate
SAMPLE_RATE = 8000 # Hz
NUM_SAMPLES = int(SAMPLE_RATE * DURATION / 1000)

# Generate the saw wave samples
samples = []
for i in range(NUM_SAMPLES):
sample = int(255 * (i % (SAMPLE_RATE / FREQUENCY)) / (SAMPLE_RATE / FREQUENCY))
samples.append(sample)

# Play the saw wave samples through the speaker
for sample in samples:
SPEAKER_PIN.high()
pyb.udelay(sample)
SPEAKER_PIN.low()
pyb.udelay(int((1 - sample / 255) * (1 / FREQUENCY - sample / SAMPLE_RATE) * 1000000))

This code uses the math and pyb modules, which provide functions for calculating the saw wave samples and outputting them to a speaker, respectively. The code defines the pin for the speaker output, as well as the frequency and duration of the saw wave. It then calculates the number of samples to generate based on the sample rate and duration, and generates the saw wave samples using a simple formula. Finally, it plays the saw wave samples through the speaker by toggling the speaker pin high and low with a delay between each sample to control the frequency. Note that the udelay() function is used to introduce a delay in microseconds, and the calculation of this delay takes into account the current sample value to ensure the correct frequency and waveform shape.



:o

What can I say... just amazing...


User avatar
jappe
Moderator
Posts: 2439
Joined: 19 Jan 2015

03 May 2023

I use it literally every day at work, for on-demand micro-training, problem solving, and a kick start on whatever task I'm on.

Started as a Dev, then they invented DevOps, and some clever guy figured that's not enough and came up with DevSecOps.
Don't mention "FullStack".
All while new frameworks are raining down from the sky, and there doesn't seem to be time for proper training.

It's difficult to become an expert on everything.

ChatGPT is a blessing when google just doesn't cut it.

Right now, it's been extremely helpful in helping out with Apache Camel tasks within the tiny timeframe of a scrum sprint.

User avatar
fullforce
Posts: 849
Joined: 18 Aug 2018

05 May 2023

I'm not so sure about ChatGPT.

I told it to say something in 5 words.

It said something in 4 words.

So I said "I said 5 words"

Then you get the whole "I apologize blah blah"

I wouldn't sail on that.
This is a block of text that can be added to posts you make. There is a 255 character limit.

User avatar
DaveyG
Posts: 2533
Joined: 03 May 2020

05 May 2023

fullforce wrote:
05 May 2023
I'm not so sure about ChatGPT.

I told it to say something in 5 words.

It said something in 4 words.

So I said "I said 5 words"

Then you get the whole "I apologize blah blah"

I wouldn't sail on that.
At least it didn't use two words..... :D

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests