John Bradnam
Published © GPL3+

Five LEDs Puzzle

This project is a logic puzzle for the festive season in which the aim is to get all five LEDs to stay lit up.

IntermediateFull instructions provided4 hours600
Five LEDs Puzzle

Things used in this project

Hardware components

Microchip Technology ATtiny13a
DIL variant
×1
IC & Component Socket, 8 Contacts
IC & Component Socket, 8 Contacts
×1
Resistors
5 x 330 ohm 1/8 watt 1 x 10K ohm 1/8 watt
×6
Capacitor 100 nF
Capacitor 100 nF
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×6
3 mm LED: Red
3 mm LED: Red
×5

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

STL file for 3D printer

0.2mm layer height, no supports required

Schematics

Schematic

PCB

Eagle Files

Schematic and PCB in Eagle format

Code

FiveLEDPuzzleV1.ino

C/C++
//Five LEDs Puzzle
//http://www.technoblogy.com/show?3CZH

void setup() 
{
  PORTB = 0;
  DDRB = 0;
}

void loop() 
{
  for (int b=0; b<5; b++) 
  {
    int d = DDRB;
    DDRB = d & ~(1<<b);
    delay(1);
    if (!(PINB & 1<<b)) 
    {
      while (!(PINB & 1<<b));
      DDRB = d ^ ((!b || (d & ((1<<b)-1)) == 1<<(b-1))<<b);
    } 
    else 
    {
      DDRB = d;
    }
    delay(10);
  }
}

Credits

John Bradnam

John Bradnam

76 projects • 66 followers
Thanks to Technoblogy.

Comments