Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #define BAUDRATE 9600UL
- #define PRESCALE (((F_CPU / (BAUDRATE * 16UL))) - 1)
- #define LED_PIN (1<<5)
- #define LED_PORT PORTB
- #define LED_DDR DDRB
- int main (void)
- {
- uint8_t cmd;
- LED_DDR |= LED_PIN;
- UCSR0B |= (1<<RXEN0)|(1<<TXEN0);
- UBRR0 = PRESCALE;
- for(;;) {
- while ( !(UCSR0A & (1<<RXC0)) );
- cmd = UDR0;
- if (cmd == '1') {
- LED_PORT |= LED_PIN;
- } else if (cmd == '0') {
- LED_PORT &= ~LED_PIN;
- } else {
- LED_PORT ^= LED_PIN;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement