Ein Multicolor LED mit der Adafruit Library zum Leuchten bringen
- Vorbedingung: Die Adafruit Library muss installiert sein
Code für den Arduino:
#include <Adafruit_NeoPixel.h> // Which pin on the Arduino is connected to the NeoPixels? #define PIN 6 // On Trinket or Gemma, suggest changing this to 1 // How many NeoPixels are attached to the Arduino? #define NUMPIXELS 1 // Popular NeoPixel ring size Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); void setup() { pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) pixels.clear(); // Set all pixel colors to 'off' } void loop() { pixels.setPixelColor(0, pixels.Color(150, 0, 0)); // red pixels.show(); // Send the updated pixel colors to the hardware. delay(1000); pixels.setPixelColor(0, pixels.Color(0, 150, 0)); // green pixels.show(); // Send the updated pixel colors to the hardware. delay(1000); pixels.setPixelColor(0, pixels.Color(0, 0, 150)); // blue pixels.show(); // Send the updated pixel colors to the hardware. delay(1000); }
Anschluss: Entweder kommt das LED auf einer kleinen roten Platine oder mit drei farbigen Kabeln. Je nachdem entsprechend anschließen.