sperma
unknown
plain_text
3 years ago
894 B
4
Indexable
#include <avr/io.h> #include <util/delay.h> #include "hd44780s/hd44780.hpp" #include <stdio.h> int main(void){ uint8_t i =0; char str[12]; DDRB |= (1<< DDB2) | (1<< DDB3) | (1<< DDB4) | (1<< DDB5); PORTB |= (1<<PORTB2) | (1<<PORTB3) | (1<<PORTB4) | (1<<PORTB5); DDRD &= ~(1<<DDD0) | ~(1<<DDD1) | ~(1<<DDD2) | ~(1<<DDD3); LCD_Initalize(); while(1){ if (!(PIND & 1<<PIND3)){ PORTB ^= (1 << PORTB2); _delay_ms(300); } else if(!(PIND & 1<<PIND2)){ LCD_GoTo(0,0); LCD_WriteText("button pressed"); } else if(!(PIND & 1<<PIND1)){ sprintf(str, "sprintf: %d", i); LCD_GoTo(0,0); LCD_WriteText(str); _delay_ms(1000); i = i+1; } else if(!(PIND & 1<<PIND0)){ PORTB = PORTB-1; _delay_ms(100); } else { PORTB |= (1<<PORTB2) | (1<<PORTB3) | (1<<PORTB4) | (1<<PORTB5); LCD_Clear(); } } }
Editor is loading...