Differences

This shows you the differences between two versions of the page.

Link to this comparison view

et:examples:setup:demo [2010/11/07 22:16] – tekitatud raivo.sellet: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 <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);
 +
 + }
 +}
 +</code>
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0