How dependable is AI?

Still new to Arduino and the forums. Hope I am on the right page.
I am currently working on a project to automate the roof of my Astronomical Observatory. I have most all the hardware installed and wired. A few components remain to be built.
I have drawn up a wiring schematic for the project. It is crude, but should point out the general components and wiring.
I wrote out all the functions I wish to achieve and pasted it to Chat GTP and received an impressive code in return.

The question is, is this program legitimate?

I do not know programming, beyond the basic tutorials. So, I am shaking in my boots to try it out. I really could use some "hand holding" regarding this.

I can provide all the information I have. I would like to see if this works.

I do not want to step on any toes or take advantage of anybody's skills here. If compensation is needed, I'll provide it. If someone wants to just review it out of curiosity, that is fine, as well.

Thanks,
Dale W.

Beginners share code on this forum, that was written by ChatGPT, when it does not work. They don't share ChatGPT-written code here when it does work, why would they? So the forum only ever sees the bad code and as a result ChatGPT has a poor reputation here.

By all means post it, along with your schematic. You have been open about where it came from.

Why not test it using a simulator? Wokwi is quite a popular simulator here.

Why not test it using an actual Arduino circuit? Replace any high-power components with simple led indicators for the test.

EDIT: to answer your subject question: less dependable than an average programmer. The AI takes code written by expert, average and beginner programmers as it's training dataset. But it isn't able to distinguish between beginner Vs expert.

3 Likes

Put the generated code in the IDE and let it compile
If it compiles do your tests.

Let's assume nobody else has a observatory like you have - so the only one who can test is you.

like any code, requirements need to be complete, correct and unambiguous and often require more than half the effort to complete the project.

development and testing will often identify outages: missing details, minor errors and ambiguities.

how sure were you that your specifications were complete, correct and unambiguous?

and if you do identify an outage, are you going to find locate the problem in the code and fix it, if possible, or go back to ChatGpt with a new specification

Please, post the functions you have outlined and the codes you received from AI in order to allow the readers to asses the correctness of the functions and the codes.

AI is neither "artificial intelligence", nor is it dependable.

However, if you use chatGPT to generate code and it does what you want, fine! If not, you might have trouble finding someone to fix it.

3 Likes
  • Go to a WEB site other than this one for help to make things work.

  • Seriously, if you want to learn coding, DIY.

1 Like

If I may butcher my language: Depending on the areas of interest, "intelligence" means "information," that is to say, one can gather "intelligence." The same goes with "artificial" with a few meanings "invented, unnatural, fake."

Therefore, "Artificial Information" can be synonymous with "Fake Information"
(oops... I meant to write "Artificial Intelligence = Fake Information")

Push to takeoff" and "Push to land" are buttons being used in aircraft since the early 2000s... and then handoff control to AutoPilot. ChatGPT is your pilot today! Let's hope it gets the pin state right this time.

The world changes and how people learn things changes over time. I've been repairing my own vehicles and equipment for decades, but YouTube definitely speeds some things up and helps me avoid mistakes when doing something new.

Likewise, ChatGPT is now part of the code development process for many people. Things won't go backwards, so we may as well learn to deal with it.

  • Maybe. :woozy_face:

  • Tesla often cannot or will not fix simple battery compartment problems, $15,000 fixes are their solution, replacement of the power plant . . .

  • I’m quite happy to know my life (< 15 years left) will never include the conversion to an EV.

Here are the dropbox links to the schematic and instructions/code sheets. Let me know what you think.

https://www.dropbox.com/scl/fi/04dsbosbt0xl4fcj5dmhj/Arduino-observatory-roof-basic-instructions.rtf?rlkey=ya0g6c0gbkknsmblg2b8rm7er&st=95co9b39&dl=0

Just ask Chat GPT.
"how many Rs are they in raspberry"
And see if it knows.
Spoiler it doesn't.

1 Like

I could only find the code and not the schematic.

That code is rubbish and needs a lot of work on it.

Is inorganic sugar a fake sugar that is no good for health?

Please, open the codes, format them in the Arduino IDE, and then post them here.

Comparing oranges and typewriters.

It’s not AI, it’s Al !

Assisted laziness.

If writing code is too hard, take up another less dangerous hobby like car rallying.

2 Likes

How sure are you of your hardware?

There is a section of the forum named Gigs and Collaborations.

I am one of those who won't waste time reading big code that doesn't work, much less attempting to fix it.

Charles Niire steered telescopes with computers since 1959. You might do well to see what solutions he made public as he was still active at least into the 90's. There may be cheap working solutions available known to the astronomy community.

Here is the link from the Arduino web editor.

https://app.arduino.cc/sketches/b3e2cd6b-6bbf-4639-8a9f-613d22224ded?view-mode=preview

After editing out redundant 'RTF formating' lines the code (copied below) compiles.

// Pin Definitions
const int relayLatchPin = 4;
const int relayLatchIndicatorPin = 7;
const int latchPins[] = {8, 9, 10, 11};
const int photoEyePins[] = {0, 1};
const int relayOpenRoofPin = 5;
const int relayCloseRoofPin = 6;
const int detectOpenRoofPin = 3;
const int detectClosedRoofPin = 2;
// Timing constants
const unsigned long latchHoldTime = 15000; // 15 seconds

// States
enum State {IDLE, LATCHING, ROOF_OPENING, ROOF_CLOSING};
State currentState = IDLE;
// Variables
unsigned long latchStartTime = 0;
void setup()
{
  // Set relay and sensor pins as outputs or inputs
  pinMode(relayLatchPin, OUTPUT);
  pinMode(relayLatchIndicatorPin, OUTPUT);
  for (int i = 0; i < 4; i++)
  {
    pinMode(latchPins[i], INPUT);
  }
  for (int i = 0; i < 2; i++)
  {
    pinMode(photoEyePins[i], INPUT);
  }
  pinMode(relayOpenRoofPin, OUTPUT);
  pinMode(relayCloseRoofPin, OUTPUT);
  pinMode(detectOpenRoofPin, INPUT_PULLUP);
  pinMode(detectClosedRoofPin, INPUT_PULLUP);
  // Initialize the relays and LEDs
  digitalWrite(relayLatchPin, LOW);
  digitalWrite(relayLatchIndicatorPin, LOW);

  digitalWrite(relayOpenRoofPin, LOW);
  digitalWrite(relayCloseRoofPin, LOW);
}
void loop()
{
  switch (currentState)
  {
    case IDLE:
      checkScopePark();
      break;
    case LATCHING:
      handleLatching();
      break;
    case ROOF_OPENING:
      handleRoofOpening();
      break;
    case ROOF_CLOSING:
      handleRoofClosing();
      break;
  }
}
void checkScopePark()
{

  if (digitalRead(photoEyePins[0]) == LOW && digitalRead(photoEyePins[1]) == LOW)
  {
    // Scope park detected; proceed to open roof
    currentState = LATCHING;
    latchStartTime = millis();
    digitalWrite(relayLatchPin, HIGH);
    digitalWrite(relayLatchIndicatorPin, HIGH);
  }
}
void handleLatching()
{
  if (millis() - latchStartTime >= latchHoldTime)
  {
    // Latching time expired, check latch release
    bool allLatchesReleased = true;
    for (int i = 0; i < 4; i++)
    {
      if (digitalRead(latchPins[i]) == LOW)
      {
        allLatchesReleased = false;
        break;
      }
    }
    if (allLatchesReleased)
    {
      // Latches released, proceed to open roof
      currentState = ROOF_OPENING;
      digitalWrite(relayLatchPin, LOW);
      digitalWrite(relayLatchIndicatorPin, LOW);
      digitalWrite(relayOpenRoofPin, HIGH);
    }
  }
}
void handleRoofOpening()
{
  if (digitalRead(detectOpenRoofPin) == LOW)
  {
    // Roof is open
    digitalWrite(relayOpenRoofPin, LOW);
    currentState = IDLE; // Return to idle state
  }
}
void handleRoofClosing()
{
  if (digitalRead(detectClosedRoofPin) == LOW)
  {
    // Roof is closed
    digitalWrite(relayCloseRoofPin, LOW);
    currentState = IDLE; // Return to idle state
  }
}
// Function to close the roof (called from IDLE state)
void closeRoof()
{
  currentState = ROOF_CLOSING;
  digitalWrite(relayCloseRoofPin, HIGH);

  // Wait for the roof to close
}

Does it do what you want?