Flickering Flames


This is a guide that brings together a series of guides and information I discovered when looking for fun projects. It uses deadbugging to create a stand-alone functioning circuit. This is based on the beautiful project on Tinker Log for a ‘geeky advent’. It’s my first circuit sculpture!

I will be making this flickering lights, light-activated, to put in a forest area nearby where I live, to give it to other walkers in the area, that will be seen at night. It is a very low light so will not disturb the environment. I am going to modify it to add a little solar panel to keep the battery charged so it should last for a very long time!

the Project

The project as detailed on Tinker Log is a great starting point to have a look at the circuit and how they have reduced it to it’s simplest of parts. They also have code provided and reference other sites that have similar circuits.

The function is to have a small all-in-one flickering circuit, it is programmed on an ATtiny and runs off a small coin cell battery. One of the LEDs is also used to sense the amount of light, and when it is dark, this circuit produces the flickering light effect.

The circuit and code we are building as on Tinker Log:
“The nice thing about this circuit is, that it needs no special components to detect darkness. It uses an LED for that. An LED is also a photodiode that can detect light of the same wavelength it emits. See here for more details. Sprite ( Sprite’s minimalistic version ) used an available ADC of the ATtiny13 instead of the “Reverse Bias” method.”

component list

image of components
  • ATtiny13 (or 25/45/85 etc)
  • 4 LEDs use 3mm (not 5mm as shown in the photo)
  • 3V Coin Cell Battery CR2032 (230 mAh)
  • extra wire (I used enamelled copper wire)/ mounting method

A simple component list, this can be made very cheaply! (and would make fun gifts for people)

ATtiny details

For information about ATtiny IC you can read about it on RS. I’ve included the pinout information as well as an image of the chip https://www.rs-online.com/designspark/basics-of-attiny85


pin information for ATtiny

  • Pin 1: analogue pin ADC0 and is used for analogue sensors
  • Pin 2: is analogue pin ADC3, also for crystal oscillator XTAL1
  • Pin 3: analogue pin ADC2 and used for crystal oscillator XTAL2
  • Pin 4: should be connected to GND
  • Pin 5: used as MOSI for SPI communication, and SDA for I2C communication
  • Pin 6: used as MISO for SPI communication
  • Pin 7: used as SCK for SPI communication and SCL for I2C communication
  • Pin 8: the Vcc Pin 5V
pin out information

next Step: Programming

arduino in case

There is a comprehensive guide online
https://www.electronics-lab.com/project/how-to-program-attiny13attiny13a-using-arduino-ide/ that demonstrates step-by-step how to program your ATTiny. First, program the bootloader onto the chip so you can then program it as you would for an Arduino board.

connecting the ATtiny to your Arduino Uno

Connect Arduino 5V to ATtiny Pin 8. Also, connect GND to Pin 4, Pin 13 to Pin 7, Pin 12 to Pin 6, Pin 11 to Pin 5, and finally Pin 10 to Pin 1.

ATtiny85 Arduino Board: How to Flash the Arduino Bootloader and ...
Great circuit diagram from Maker Portal with
Electrolytic Capacitor (10uF), I didn’t use one.

You should follow the guide on electronics lab but the general steps are after hook up:

  1. Program ATtiny13: set Arduino as a programmer. This happens by uploading ArduinoISP sketch to Arduino following this path (Files -> Examples -> ArduinoISP) in the IDE.
  2. Install core files needed:
    To install these files, open your Arduino IDE and navigate to the files drop-down menu, then select preferences. Paste this URL “https://raw.githubusercontent.com/sleemanj/optiboot/master/dists/package_gogo_diy_attiny_index.json” where it says “Additional Boards Manager URLs:”. If you already have a URL here and want to add more, separate the URLs with a comma and a space.
  3. Now, navigate to tools-board and click on Boards Manager…. Now scroll down until you see DIY ATtiny and click the install button.
  4. In order to start programming ATtiny 13, we must burn Bootloader to it. There are two steps to achieve this: first, go to Tools >Board and select ATtiny13,
    Note: Pay attention to your ATtiny version, navigate to Tools > Processor Version and select either ATtiny13 or ATtiny25 depending on your chip. (mine is a ATtiny25)
  5. tools > programmer > Arduino as ISP
  6. and second, click the Burn Bootloader button at the bottom of the tools drop-down menu.


If you see the success message then you are ready to try the ATtiny.
Try an Arduino IDE example like the Blink sketch.

How the circuit will look when completed.

simple LED Blink sketch

Upload the sketch to the ATtiny13 (using the Uno board and the ‘Arduino as ISP’ programmer and wiring) – then you have a fully-functional Arduino ATtiny13!

int led_pin = 4; 

void setup() {

void loop(){
Adding a single cell battery to power the chip and leds!

modified code for flicker LED effect

Once you have been able to load up the blink code successfully, you can upload the flickering LEDs code that has been provided in the original post at Tinker Log. There was only a tiny modification to get it to work in Arduino.

Choose the correct board and board settings. Below are some of the settings I’ve used.

Options in Arduino
Options in Arduino accessed via the Tools menu.

/* -----------------------------------------------------------------------
 * Title:    advent.c
 *           Flicker 4 LEDs
 * Author:   Alexander Weber
 *           http://tinkerlog.com
 * Date:     22.11.2009
 * Hardware: ATtiny13v
 * Software: CrossPack-AVR-20090415
 * Credits:
 * This code is based heavily on sritesmods version.
 * Find the original at http://spritesmods.com/?art=minimalism&f=gpl
 * Changes:
 * - support 4 LEDs
 * - added a bit of sampling for light detection
 * - moved the "power down" out of the ISR, was always resetting
 * - removed callibration, replaced by hardwired value.

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>
#include <avr/sleep.h>
#include <avr/wdt.h>

#define LED1  PB4 
#define LED2  PB3
#define LED3  PB2
#define LED4  PB1
#define ADC2 2
#define AMBIENT_LIGHT 300

#define TRUE 1
#define FALSE 0

//Bunch o' random numbers: I'm too lazy to write or port a real random number
//generated using bash:
//for x in `seq 0 255`; do echo -n $(($RANDOM%256)),; done
uint8_t const randomvals[] PROGMEM = {

uint8_t mode_ee EEMEM = 0;                      // stores the mode in eeprom
static volatile uint8_t sleep = 0;

// Gets a semi-random number between 0 and 255
uint8_t getRandom(void) {
  //This'll probably give a warning because we use it uninitialised. Little 
  //does the compiler know: that's actually what we _want_ :)
  static uint8_t random1, random2;
  if (random1 == 0) {
    random2 += 0x41;
  return pgm_read_byte(randomvals + random1) ^ random2;

uint16_t getLight(void) {
  uint16_t val = 0;
  uint8_t i;

  // measure pb4 using internal ref
  ADMUX = (1 << REFS0) | ADC2;             
  // enable ADC, prescaler 8
  ADCSRA = (1 << ADEN) | 3;
  // kill all leds
  PORTB &= ~((1 << LED1) | (1 << LED2) | (1 << LED3) | (1 << LED4));

  // let led generate some voltage
  DDRB &= ~(1 << LED1);

  // warm up the ADC, discard the first conversion
  ADCSRA |= (1 << ADSC);
  while (ADCSRA & (1 << ADSC)); 
  for (i = 0; i < 4; i++) {
    ADCSRA |= (1 << ADSC);
    while (ADCSRA & (1 << ADSC)); 
    val += ADC;
  val >>= 2;
  ADCSRA = 0;             // disable adc
  DDRB |= (1 << LED1);    // re-enable led

  return val;

void powerDown(void) {
  // Go to sleep until we're woken up by the wdt.

ISR(WDT_vect) {
  //check if it's still dark
  sleep = (getLight() > AMBIENT_LIGHT) ? TRUE : FALSE;

int main(void) {
  uint8_t lval1, lval2, lval3, lval4;
  uint8_t i, x, y;
  uint8_t mode;

  // set up wdt

  WDTCR |= 0x40; // WDT generates interrupts instead of resets now.
                 // We want interrupts because a reset clears our nice random
                 // seeds, and an interrupt doesn't.
  for (i = 0; i < 10; i++) {

  // retrieve mode from eeprom and write back mode + 1
  mode = eeprom_read_byte(&mode_ee);
  mode = mode % 4;
  eeprom_write_byte(&mode_ee, mode + 1);  


  // go directly into sleep mode and lets wake up by the wdt
  sleep = TRUE;

  // enable leds
  DDRB = (1 << LED1) | (1 << LED2) | (1 << LED3) | (1 << LED4);

  while (1) {

    WDTCR |= 0x40; // make sure wdt keeps generating an int instead of a reset

    if (sleep) {
      // switch off all LEDs and power down
      PORTB &= ~((1 << LED1) | (1 << LED2) | (1 << LED3) | (1 << LED4));
    else {
      // get a random value for the leds intensity
      lval1 = getRandom();
      lval2 = getRandom();
      lval3 = getRandom();
      lval4 = getRandom();    
      // Manually do some pwm
      for (x = 0; x < 20; x++) {
  if (mode == 0) {
    PORTB |= (1 << LED1);
  else if (mode == 1) {
    PORTB |= (1 << LED1) | (1 << LED2);
  else if (mode == 2) {
    PORTB |= (1 << LED1) | (1 << LED2) | (1 << LED3);
  else if (mode == 3) {
    PORTB |= (1 << LED1) | (1 << LED2) | (1 << LED3) | (1 << LED4);
  for (y = 0; y != 255; y++) {
    if (y == lval1) {
      PORTB &= ~(1 << LED1);
    if (y == lval2) {
      PORTB &= ~(1 << LED2);
    if (y == lval3) {
      PORTB &= ~(1 << LED3);
    if (y == lval4) {
      PORTB &= ~(1 << LED4);

Soldering the initial ring of LEDs, all negative legs (cathodes) form the ring shape.

soldering the Circuit

  • All cathodes of the LEDs are connected to form the ring.

I first took 4 LEDs to sacrifice and practice bending the ground leg of them into this circle form. I then tried a few different ways to solder them together. In the end, I put the anode (positive) leg into a mini breadboard to hold them once they were already bent into shape. Then I used a crocodile clip to hold the leg together in place as I soldered it.

  • The anodes are bent inwards to be soldered to pin 2, 3, 6 and 7 of the ATtiny13.
  • Use wire to connect the common cathode (soldered) to the GND pin.
  • The GND pin is then connected to GND of the battery.


Dietz, P.H., Yerazunis, W.S., Leigh, D.L., “Very Low-Cost Sensing and Communication Using Bidirectional LEDs”ACM International Conference on Ubiquitous Computing (UbiComp), October 2003. PDF Download

Tutorial Online on Tinker Log [Accessed April 20, 2020].

Comprehensive guide online to programming an ATtiny Online Available:
https://www.electronics-lab.com/project/how-to-program-attiny13attiny13a-using-arduino-ide/ [Accessed April 18, 2020].

Installing additional boards,
https://raw.githubusercontent.com/sleemanj/optiboot/master/dists/package_gogo_diy_attiny_index.json to add the ATtiny to Arduino Available Online [Accessed April 15, 2020].

Circuit diagram online available from Maker Portal [Accessed April 18, 2020].

Another version of the circuit via Sprite Sprite’s minimalistic version Available online [Accessed April 20, 2020].


Have you made an aircircuit or done deadbugging before? Do you have any small projects? What skills have you been working on? Drop me a comment!

First iteration prototype Crumpler 1.0

First iteration prototype Crumpler 1.0   

Write up of some of the details from the Crumpler Prototype.

Details: iteration 1.0 This change was the first proposal after working through the proof of concept prototype there were issues to address and further investigate. Initial changes from the testing prototype bag was removing the LCD screen, because I was trying to scale down and wanted the simplest of communication with the user. The following table is the items that were used to build this bag. There was a period of testing different circuit boards for their compatibility, programmability and aesthetics. After researching the available components at this time the LilyPad series of items seemed the most relevant as it offered a way to use components that could be attached to the outer surface of the bag, therefore leaving the bulk of the bag mostly unaltered. No compromise on space or weight for the original bag.  

USB LiPoly Charger to charge 3.7V LiPo cells at a rate of 500mA or 100mA per hour. It is designed to charge single-cell Li-Ion or Li-Polymer batteries. The board incorporates a charging circuit, status LED, selectable solder jumper for 500mA or 100mA charging current, external LED footprint, USB input, mounting holes. There is also a ‘SYS OUT’ which allows you to connect the charging circuit directly to your project so you don’t need to disconnect the charger to use.This is a very slow way to charge the batteries, and this is an issue that will need to be addressed.
LilyPad Buzzer This is a small buzzer, use 2 I/O pins on the LilyPad main board and create different noises based on the different frequency of I/O toggling. Loud enough to hear inside a pocket but not obtrusively loud. 20mm outer diameter Thin 0.8mm PCB
SLO18 RFID reader 5V Supports Mifare 1K, Mifare 4K and Ultralight. It does auto Real-time detecting tag which moves into or out of detective range and reports through one output pin’s logic level. In addition, it integrates all necessary components and antenna in one PCB. Frequency : 13.56MHz Protocol : ISO14443A Tag supported : Ultralight, Mifare Mini, Mifare 1K, Mifare 4K, FM11RF08 Interface : I2C Supply voltage : 4.4 – 7.0VDC Dimension : 65 × 45 mmUsing this RFID reader would mean finding a board suitable to work with the 5V requirement.
Polymer Lithium Ion Battery – 6AhrEach cells outputs a nominal 3.7V at 2000mAh – 3 cell pack (6Ahr) is terminated with a standard 2-pin JST-PH connector – 2mm spacing between pins.The 3.7V may be an issue that needs looking into – to get enough power to the board to light the LEDs/
Lilypad 328 Main Board has more I/O ports to access and use for tags / LEDs and operated at 5v so the reader choice had to meet with the same voltage.It has an ATMega328 and Arduino bootloader. It supports automatic reset 55mm outer diameter 0.8mm PCB
Slide Switch Simple slide switch to power ON/ OFF the bag. It can be used to switch other things, but that is it’s purpose for this bag. 7.75×18.1mm Thin 0.8mm PCB
FTDI basic Breakout 5V This is only needed for programming the board, and can be used with all the 5V boards to program. USB to serial IC. The pinout of this board matches the FTDI cable to work with official Arduino and cloned 5V Arduino boards. It can also be used for general serial applications. The major difference with this board is that it brings out the DTR pin as opposed to the RTS pin of the FTDI cable. The DTR pin allows an Arduino target to auto-reset when a new Sketch is downloaded. This is a really nice feature to have and allows a sketch to be downloaded without having to hit the reset button. This board will auto reset any Arduino board that has the reset pin brought out to a 6-pin connector.This board has TX and RX LEDs.

Details of Testing Programme

This prototype is a departure from the first proof of concept bag. It was carried around on all my daily journeys to test the bag initially for working issues, sociability and general fixes that would need to be done before testing it with a user.

Results and Conclusions for next Iteration

This bag I used on a daily basis from March 2013 until May 2013, and then less frequently due to moderations / user testing from June –July 2013. The bag is used daily highlighted a lot of issues. Comments from this time period: The importance of the placement of the on / off switch – it was hit accidentally a few times, and I didn’t realise some times – so moving it to better placement / alternative, and maybe adding a vibe board to alert the user that the bag had switched on, so if it was knocked then they would be made aware. With this first iteration, due to the much larger amount of LEDs (the first system had 5 this one has 13), I would have to place a small card in the bag to remind the user of the items and the corresponding colours as there were a lot of LEDs. This doesn’t seem as practical and I did have people asking me how I would / or how someone would remember the LEDs and what they were for. This needs addressing. The battery weight and charging would need to be addressed, there isn’t a clear way currently to be aware if the bag is low on battery power or how long it needs to charge. After using the bag, I wanted notifications to be more intense the nearer to the time the event / leaving etc, happened… this is scope for future work and implementation because I’m not sure how this could work. There was an occasion where I had forgotten my student card and I needed it so as I was leaving it would have been good to have gotten a more urgent notification of some sort. Perhaps indicating the items importance/use or urgency. I was trying to maximize the number of tags that could be read, but I think this would overload a user. Lastly, it does work in the rain and the battery casing is inside the bag so there is no issue from that aspect too.