ChatGPT Creates Arduino Code
HTML-код
- Опубликовано: 5 сен 2024
- In this video, Dave uses ChapGPT 4o to create code to program an Arduino for a Digital Thermometer project. Join Dave as he walks you through this project.
Dave also used the DALL-E AI to create the robot programming an Arduino graphic.
Here is the prompt I used for the graphic:
Create a photo of chatgpt writing code to program an Arduino Uno
Here is the prompt I used to create the Arduni code:
Please create an arduino program for an arduino uno that measures temperature and displays that temperature in degrees F on a 2 line LCD display that has a serial interface using a backpack board. The temperature probe is a dallas semiconductor probe. also, please show a wiring diagram for the project and an explanation of how it works.
Awesome...I tested it on version 3.5 with a simple servo motor and controlled with a potentiometer. Worked first try.
You're right about the importance on writing the prompt. I'm excitedto try 4.0
Super cool !! Nice Video !! Makes better sense to me now Thank you kind Sir
Impressive video! Just right for those wanting to get started programming an Arduino.
Even though I have done Arduino programming I learned something.
Well done!
I've asked 3.0 to generate code for a side project I had in mind but was too lazy to read up and figure out. The pivotal method's body was only a comment saying something like; "this is left up to the reader as an exercise" I asked it then to populate that specific method, knowing the inputs and outputs required. It regenerated the whole piece of code and hid that method deeper in the code, but still same comment. I find it too eager to please and will make up stuff. I'm glad it worked for you.
I used the latest ChatGPT 4o on this experiment. That is "o" as in Oscar-which is supposedly much better. I have used ChatGPT 3 and found it to hallucinate frequently.
Nice information and example. Well laid out and agreeable conclusion presented. I liked the power tool anolagy.
Glad you liked it!
Great video! Keep up the good work with the Arduino
you deserved a lot off subscribers bro
Yes it can. But if it’s really super complicated, no. Like when your RTC trumps the GPS system you’re using in your project.
Creative video,thanks :)
Thank you! Cheers!
I noticed that you started the video with an Arduino R4 but the finished test was using an R3, were there issues with the R4 as I was planning on getting one?
Good eye! The LCD panel actually had a problem. In switching out parts to find the issue, I substituted an R3 as part of the diagnosis steps. I tested the R4, and it works fine. Thanks for the question.
@@daveintheshop Thanks for that. I'm very new to Arduino stuff so a lot of stuff I'm trying doesn't work at the moment haha. I'll get better though. Thanks for clarifying. 🙂
Here is the code response from ChatGPT
Here is the code that was generated by ChatGPT:
#include
#include
#include
#include
// Data wire is connected to pin 2
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// Start the serial communication
Serial.begin(9600);
// Start up the library
sensors.begin();
// Initialize the LCD
lcd.begin();
lcd.backlight();
// Print a message to the LCD
lcd.setCursor(0, 0);
lcd.print("Temperature:");
}
void loop() {
// Request temperature from the sensor
sensors.requestTemperatures();
// Fetch the temperature in Celsius
float tempC = sensors.getTempCByIndex(0);
// Convert Celsius to Fahrenheit
float tempF = tempC * 9.0 / 5.0 + 32.0;
// Print the temperature in Fahrenheit on the LCD
lcd.setCursor(0, 1);
lcd.print(tempF);
lcd.print(" F");
// Wait 1 second before repeating
delay(1000);
}
The major problem with this method is that you've learnt nothing. You might as well have bought a working temperature readout device. You will have learnt nothing there too.