// 2010 Kenneth Finnegan | |
// kennethfinnegan.blogspot.com | |
// | |
// Drives cross walk sign in standard cycle | |
// Outputs buffered through 400V TRIACs | |
// Runs on standard ATTiny85 with internal oscillator | |
#include <inttypes.h> | |
#include <avr/io.h> | |
#include <avr/interrupt.h> | |
#include <util/delay.h> | |
#define POWER_LINE (0x08) | |
#define WALK_LATCH (0x10) | |
// CONSTANTS | |
#define XTAL 8000000L // Crystal frequency in Hz | |
// Wrapper for _delay_ms macro to save flash space | |
void delay_ms (unsigned int i) { | |
unsigned int j; | |
for (j=i; j; j--) { | |
_delay_ms(1); | |
} | |
} | |
int main(void) | |
{ | |
// Initialize port direction | |
DDRB = POWER_LINE | WALK_LATCH; | |
PORTB = 0x00; | |
int i; | |
while (1) { | |
// Latch the walk signal | |
PORTB = POWER_LINE | WALK_LATCH; | |
delay_ms(500); | |
PORTB = POWER_LINE; | |
delay_ms(9500); | |
// Flash the hand | |
for (i=0; i<10; i++) { | |
PORTB = 0; | |
delay_ms(500); | |
PORTB = POWER_LINE; | |
delay_ms(500); | |
} | |
// Hold the hand | |
delay_ms(20000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment