Code per KI - ChatGPT

Hallo zusammen,

gestern hat mir ein Bekannter von ChatGPT erzählt.
Einer KI die per Anfrage fast alles macht.
Sie schreibt sogar Programme!!!

Hier ein Beispiel, das ich eben angefragt habe:
Anfrage:

i need a c++ code for a neopixel Ring with 12 LEDs. The code should let the neopixel module pulse 3 times

Antwort der KI:

Here is an example of C++ code that can be used to control a NeoPixel ring with 12 LEDs and make it pulse 3 times:

Copy code

#include <Adafruit_NeoPixel.h>

#define PIN 6
#define NUMPIXELS 12

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.begin();
  pixels.show(); // Initialize all pixels to 'off'
}

void loop() {
  for(int i = 0; i < 3; i++) { // Pulse 3 times
    for(int j = 0; j < 256; j++) { // Fade in
      pixels.setBrightness(j);
      pixels.show();
      delay(10);
    }
    for(int j = 255; j >= 0; j--) { // Fade out
      pixels.setBrightness(j);
      pixels.show();
      delay(10);
    }
  }
}

This code uses the Adafruit NeoPixel library to control the NeoPixel ring. In the setup function, the NeoPixel object is created and initialized, and in the loop function, the code makes the ring pulse 3 times by gradually increasing and decreasing the brightness of the LEDs.

Please note that this code is just an example and you may need to adjust the pin configuration and library to match your specific hardware.

Ein seeeehr nützliches Werkzeug und sicher ein Einblick in die Zukunft des Internets!

Ergänzung, die KI spricht auch deutsch :wink:

Leider überlastet:
„A timeout occurred Error code 524“

ich bin aktuell auf dem server drauf, vieleicht etwas warten?

P.S. ich glaube ich hab ein neues Lieblingsspielzeug:

can you write a c+ code wich plays an mp3 via DFPlayer, after you bring a nfc tag over nfc reader

Here is an example of C++ code that plays an MP3 using the DFPlayer module after an NFC tag is read by an NFC reader:

#include <Wire.h>
#include <DFRobotDFPlayerMini.h>
#include <Adafruit_PN532.h>

// Create an instance of the DFPlayer mini class
DFRobotDFPlayerMini myDFPlayer;

// Create an instance of the NFC reader class
Adafruit_PN532 nfcReader;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize the DFPlayer
  myDFPlayer.begin();
  myDFPlayer.volume(20); // Set volume to 20

  // Initialize the NFC reader
  nfcReader.begin();
}

void loop() {
  // Check if an NFC tag is present
  uint8_t success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
  success = nfcReader.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
  if (success) {
    // An NFC tag is present, so play the MP3
    myDFPlayer.play(1);
    delay(5000); // Wait for 5 seconds
  }
}

Please note that this is just a sample code and you may need to adjust it to match the specific configuration of your hardware. Also, you will need to install the DFRobotDFPlayerMini and Adafruit_PN532 libraries in order to use the DFPlayer and NFC reader classes respectively.

1 „Gefällt mir“

So kannst ihn auch Code auf Fehler untersuchen lassen… Er findet sogar Fehler am eigenen Code :slight_smile:

Nur so aus Neugierde, funktioniert euer Code auch?