In this simple example for a Digispark board we connect an Neopixel strip to it. We will then use the Arduino IDE to write a sketch and upload it to the board.
I used an OLIMEXINO-85 but a basic Digispark will work as well
Schematic
Its a Neopixel strip so its easy to connect to the Digispark boards, you just need 5v, Gnd and select the data pin. We use
Parts
A Digispark, LED strip and some wires to connect the LED strip to the Digispark. the one I used for t his example is th 16 LED square one in the image below (35mm). Anyone will work.
£2.19 from Aliexpress | |
£0.85 from Aliexpress | |
£1.18 from Aliexpress | |
Examples
This example uses the Adafruit_Neopixel library which is installed with the Digispark
You need to change the Pin used and the number of LEDs fitted in the Neopixel strip
We do this like this
// Which pin on the Arduino is connected to the NeoPixels? #define PIN 0 // How many NeoPixels are attached to the Arduino? #define NUMPIXELS 16
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 0
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 16
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);
int delayval = 500; // delay for half a second
void setup()
{
pixels.begin(); // This initializes the NeoPixel library.
}
void loop()
{
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
for(int i=0;i<NUMPIXELS;i++)
{
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,25,0)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}