Elijah Scheele
Published © GPL3+

Hardware Hack Night Start!

Basic setup and control of WS2812 led pixels for Hardware Hack Night Santa Monica.

BeginnerProtip15 minutes4,027
Hardware Hack Night Start!

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
We're using a nano clone with a CH340G usb-serial chip
×1
WS2812 LED pixel strip
×1

Story

Read more

Code

Serial LED Example

Arduino
Some starter code to give you direct control of each LED from the serial console
#include <Adafruit_NeoPixel.h>

#define PIN 2 //LED PIN Location
#define NUM_LEDS 5 //number of leds

int inputCount = 0;
int serialArr[4];
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
int incomingByte; //read incoming serial data

void setup() {
  // setup pixel strip and show() nothing
  strip.begin();
  strip.show();

  //start serial port at 115200 bps
  Serial.begin(115200);

}

void loop() {
  //send (pixel, R, G, B) over serial
  //lights pixel with color

  if (inputCount == 4){
    inputCount = 0;
    strip.setPixelColor(serialArr[0], serialArr[1], serialArr[2], serialArr[3]);
    strip.show();
  } else {
  // read bytes from serial
    while(Serial.available()>0)
    {
      int input = Serial.parseInt();
      serialArr[inputCount] = input;
      inputCount++;
    }
  }
}

Credits

Elijah Scheele

Elijah Scheele

9 projects • 60 followers
Developer interested in all sorts of cool projects.

Comments