/* Tiny Time Watch David Johnson-Davies - www.technoblogy.com - 3rd December 2016 ATtiny85 @ 1 MHz (internal oscillator; BOD disabled) CC BY 4.0 Licensed under a Creative Commons Attribution 4.0 International license: http://creativecommons.org/licenses/by/4.0/ */ #include #include const int now = 1547; // To set the time; eg 15:47 const int Tickspersec = 250; // Ticks per second volatile byte Ticks = 0; volatile unsigned long Secs = (unsigned long)((now/100) * 60 + (now%100)) * 60; volatile int Timeout; volatile byte Cycle = 0; volatile boolean DisplayOn = false; volatile int Step; // For setting time volatile int Hours = 0; // From 0 to 11 volatile int Fivemins = 0; // From 0 to 11 // Pin assignments int Pins[5][5] = {{-1, 10, -1, 2, 0 }, {11, -1, -1, 3, 7 }, {-1, -1, -1, -1, -1 }, { 1, 9, -1, -1, 5 }, { 6, 8, -1, 4, -1 } }; // Display multiplexer ********************************************** void DisplayNextRow() { Cycle++; byte row = Cycle & 0x03; if (row > 1) row++; // Skip PB2 byte bits = 0; for (int i=0; i<5; i++) { if (Hours == Pins[row][i]) bits = bits | 1< 250Hz TIMSK = TIMSK | 1<