Sean Hodgins
Published © CC BY-NC-SA

Zoetrope Christmas Ornament

Motors, LEDs, and Christmas trees. Make your very own electronic zoetrope and hang it on your tree.

AdvancedShowcase (no instructions)8 hours1,397
Zoetrope Christmas Ornament

Things used in this project

Hardware components

WS2812 Addressable LED Strip
Digilent WS2812 Addressable LED Strip
×1
Trinket M0
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Code

reverse_zoetrope_ornament_fastLED.ino

C/C++
Upload it to the Trinket
#include <FastLED.h>


#define NUM_LEDS 2

#define DATA_PIN 4


// Define the array of leds
CRGB leds[NUM_LEDS];


#define MOTOR 2
#define HALL 3

volatile unsigned int displayNum = 0;
volatile unsigned int lightsFlag = 0;
volatile int timer = 0;
int colours[8] = {CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green};
//int colours[8] = {CRGB::White, CRGB::White, CRGB::White, CRGB::White, CRGB::White, CRGB::White, CRGB::White, CRGB::White};
int delayval = 500; // delay for half a second

void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  Serial.begin(115200);
  pinMode(HALL, INPUT);
  pinMode(MOTOR, OUTPUT);
  digitalWrite(MOTOR, LOW);
  FastLED.setBrightness(255);
  //digitalWrite(MOTOR, HIGH);
  delay(200);
  digitalWrite(MOTOR, LOW);
  int mag = 1;
  mag = digitalRead(HALL);
  while (mag == 1) {
    mag = digitalRead(HALL);
    analogWrite(MOTOR, 25);
  }
  analogWrite(MOTOR, 0);
  delay(1000);
  attachInterrupt(HALL, LIGHTS, FALLING);
  analogWrite(MOTOR, 25);
}

void loop() {


  if (lightsFlag == 1) {
    analogWrite(MOTOR, 0);
    lightsFlag = 0;
    leds[0] = colours[displayNum];
    leds[1] = colours[displayNum];
    //while(millis()-timer<60);
    FastLED.show();
    delay(1000);
    analogWrite(MOTOR, 25);
    leds[0] = CRGB::Black;
    leds[1] = CRGB::Black;
    FastLED.show();
    displayNum++;
    if (displayNum > 7) {
      displayNum = 0;
    }

  }
}



void LIGHTS() {
  lightsFlag = 1;
}

Credits

Sean Hodgins

Sean Hodgins

21 projects • 72 followers
Just a maker who likes making.

Comments