Include lcd motors segment
#include <avr/io.h> #include <util/delay.h> #define SET(x) |= (1<<x) #define CLR(x) &=~(1<<x) #define INV(x) ^=(1<<x) int main(void) { int loendur=0; char text[16]; // Pin PB7 to output DDRB = 0x80; DDRC = 0x38; PORTC |= 0x04; segment_display_init(); lcd_gfx_init(); unipolar_init(); // Endless cycle while (1) { // Pin PB7 invertion //if (bit_is_clear (PINC,0) PORTB = 0xFF; if ( (PINC & 0x01) == 0 ) { PORTC CLR(3); } else { PORTC SET(3); } if ( (PINC & 0x02) == 0 ) { PORTC CLR(4); lcd_gfx_backlight(0); } else { PORTC SET(4); lcd_gfx_backlight(1); } if ( (PINC & 0x04) == 0 ) { PORTC CLR(5); loendur=0; } else { PORTC SET(5); } lcd_gfx_goto_char_xy(0,0); sprintf(text,"Vajutasid nuppu S%d",(PINC & 0x07)-3); lcd_gfx_write_string(text); segment_display_write(loendur%10); PORTB ^= (1<<7); PORTC ^= (1<<4); _delay_ms(400); loendur ++; unipolar_halfstep(0,1,1000,5); unipolar_halfstep(1,1,1000,5); } }