Created
September 23, 2010 22:16
-
-
Save PhirePhly/594497 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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