This shows you the differences between two versions of the page.
| et:examples:setup:demo [2010/11/07 22:16] – tekitatud raivo.sell | et:examples:setup:demo [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | Include | ||
| + | lcd | ||
| + | motors | ||
| + | segment | ||
| + | |||
| + | |||
| + | <code avr> | ||
| + | |||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | #define SET(x) |= (1<< | ||
| + | #define CLR(x) & | ||
| + | #define INV(x) ^=(1<< | ||
| + | |||
| + | int main(void) | ||
| + | { | ||
| + | int loendur=0; | ||
| + | char text[16]; | ||
| + | // Pin PB7 to output | ||
| + | DDRB = 0x80; | ||
| + | DDRC = 0x38; | ||
| + | PORTC |= 0x04; | ||
| + | |||
| + | | ||
| + | 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, | ||
| + | sprintf(text," | ||
| + | lcd_gfx_write_string(text); | ||
| + | |||
| + | segment_display_write(loendur%10); | ||
| + | PORTB ^= (1<< | ||
| + | PORTC ^= (1<< | ||
| + | _delay_ms(400); | ||
| + | loendur ++; | ||
| + | unipolar_halfstep(0, | ||
| + | unipolar_halfstep(1, | ||
| + | |||
| + | } | ||
| + | } | ||
| + | </ | ||