Things used in this project

Hardware components:
Attiny85
Atmel ATTiny85
I used the ATTiny45, but it will also work on the ATTiny85
×1
SparkFun Electrolytic Decoupling Capacitors - 100uF/25V
×1
SparkFun Electrolytic Decoupling Capacitors - 1000uF/25V
×1
SparkFun Capacitor Ceramic 0.1uF
×1
SparkFun SPDT Slide Switch
×1
SparkFun LED - RGB Addressable, PTH, 8mm
×1
SparkFun Transistor - NPN (2N3904)
×1
SparkFun 1N4001 Diode Rectifier - 1A 50V
×1
11026 02
Jumper wires (generic)
×1
12002 04
Breadboard (generic)
×1
AA Battery
×1
AA Battery Holder
×1
7mm Inner Diameter Ferrite Ring Iron Toroid
×1
22 gauge solid core wire
I used the wires inside an ethernet cable. Thinner wire works well also, just make sure it's a solid core.
×1
Software apps and online services:
Ide web
Arduino Arduino IDE

Schematics

Breadboard Diagram
Attiny joule thief neopixel

Code

CodeArduino
You should play with the WATCHDOG_SLEEP variable to speed up or slow down color transitions.
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>

#define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC (before power-off)

volatile bool f_wdt = 1;
uint16_t j = 164;

#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, 1, NEO_GRB + NEO_KHZ800);

// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms
// 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec
#define WATCHDOG_SLEEP 0

void setup() {
  adc_disable();
  setup_watchdog(WATCHDOG_SLEEP);
  
  strip.begin();
  strip.setBrightness(64);
  strip.show();
}

void loop() {
  rainbow();
}


void rainbow() {
  strip.setPixelColor(0, Wheel((j) & 255));
  strip.show();
  j++;
  
  system_sleep();
}


uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } 
  else if(WheelPos < 170) {
    WheelPos -= 85;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  } 
  else {
   WheelPos -= 170;
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  }
}


ISR(WDT_vect) {
  f_wdt = 1;
}


void setup_watchdog(int ii) {
  byte bb;
  int ww;

  if(ii>9)
    ii = 9;

  bb = ii & 7;

  if(ii>7)
    bb |= (1<<5);

  bb |= (1<<WDCE);

  ww = bb;

  MCUSR &= ~(1<<WDRF);
  WDTCR |= (1<<WDCE) | (1<<WDE);
  WDTCR = bb;
  WDTCR |= _BV(WDIE);
}


void system_sleep() {
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_enable();
  sleep_mode();
  sleep_disable();
}

Credits

Avatar
Garrett Bartley

Husband, father, maker.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Arduino Like Function on Kinetis K82 Freedom Stupid Board
Intermediate
  • 55
  • 4

Protip

1000 of K82 Freedom Boards are collecting dust because of the hobbyist unfriendly IDE, pump up the duds with easy Arduino-like functions.

Reducing Arduino Power Consumption
Intermediate
  • 144
  • 5

Full instructions

One the most important feature of portable electronics should be long battery life. We can reduce the current drawn by several ways.

Arduinomated Car Parking with Voice Assistance in Smartphone
Intermediate
  • 404
  • 9

Full instructions

Make an assistant which tells you about how much to drive backwards without any collision through your smartphone by Arduino and 1Sheeld.

Sigfox Forest Fire Detector
Intermediate
  • 2,741
  • 16

Full instructions

How to prevent forest from burning? A small Sigfox signal can prevent natural disasters. We will use an Arduino MKRFOX + a flame detector.

Remote Lamp
Intermediate
  • 350
  • 4

Full instructions

How to make a lamp controlled by TV remote control.

Arduino Word Clock
Intermediate
  • 518
  • 8

Full instructions

A clock that let you read the time, for real!

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog