Table of Contents

Arduino with Neopixel Ring Workshop

Introduction and Setup

Goal: Recap Arduino basics and set up the workspace.

Activities:

Arduino Uno R3 Pinout

Understanding Arduino Uno Hardware Design

Datasheet for the LED controller

Understanding the Neopixel Library

Goal: Understand how the Neopixel library controls the LED ring.

Activities:

Challenge:

  1. Understand how to change the color and intensity of individual LEDs using setPixelColor() where color is a combination of red, green, and blue values. This function allows for precise control over each LED's color on the ring.

Potentially useful functions (fill in the blanks!):

Adafruit Neopixel Library on GitHub Adafruit Neopixel Library Documentation Adafruit Neopixel Code Snippets

Dissecting Example Code

Goal: Apply understanding by analyzing and modifying provided example code.

Activities:

// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library
 
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
 
// Why do we have these #define instructions and how do they differ from regular variables?
 
#define PIN        6  // On Trinket or Gemma, suggest changing this to 1
#define NUMPIXELS 16  // Popular NeoPixel ring size
 
// Declare our NeoPixel strip object:
// Argument 1 = Number of LEDs in NeoPixel ring
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
 
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
 
#define DELAYVAL 500  // Time (in milliseconds) to pause between pixels
 
void setup() {
  pixels.begin();  // INITIALIZE NeoPixel strip object (REQUIRED)
}
 
void loop() {
  pixels.clear();  // Set all pixel colors to 'off'
 
  for(int i = 0; i < NUMPIXELS; i++) {  // For each pixel...
    pixels.setPixelColor(i, pixels.Color(0, 150, 0));
    pixels.show();   // Send the updated pixel colors to the hardware.
    delay(DELAYVAL); // Pause before next pass through loop
  }
}

Programming Challenge: Create Patterns

Goal: Develop custom light patterns and sequences.

Activities:

Challenges:

  1. Create a gradient effect that transitions across the Neopixel ring.
  2. Develop a “chase” sequence where a single lit LED moves around the ring.