Created
March 7, 2014 14:09
-
-
Save dwaq/9412142 to your computer and use it in GitHub Desktop.
Blink LED on ATtiny13A when switch is pressed. tinkeringetc.blogspot.com
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
#include <avr/io.h> | |
#include <util/delay.h> | |
#define SWITCH PB0 // pin 5 | |
int main(void) | |
{ | |
DDRB = 1<<4; // port B3, ATtiny13a pin 2 | |
PORTB = 1<<SWITCH; // port b0, switch input | |
while (1) | |
{ | |
if ((PINB & (1 << SWITCH))) { // switch pressed | |
for (int n=0; n<4; n++){ // blink 4 times | |
// port B3, ATtiny13a pin 2 | |
PORTB = 1<<4; // LED on | |
_delay_ms(500); | |
PORTB = 0X0; // LED off | |
_delay_ms(250); | |
} | |
} | |
else { | |
// nothing! | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment