-
Notifications
You must be signed in to change notification settings - Fork 4
/
LCDtest.c
74 lines (64 loc) · 1.18 KB
/
LCDtest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <avr/io.h>
#include <avr/delay.h>
int main()
{
DDRA=0b11111111; //Sätter utgångar
DDRC=0b11000000;
//Startar initiering
PORTA=0b00111100; // 2-line mode ; 5x8 Dots
PORTC=0b10000000;
PORTC=0b00000000;
_delay_us(400);
PORTA=0b00001111; // Display on ; Cursor on ; Blink on
PORTC=0b10000000;
PORTC=0b00000000;
_delay_us(400);
PORTA=0b00000001; // Clear display
PORTC=0b10000000;
PORTC=0b00000000;
_delay_ms(20);
PORTA=0b00000111; //Decrement mode ; Entire shift on
PORTC=0b10000000;
_delay_ms(20);
//Initiering klar
_delay_ms(4000);
while(1)
{
writechar(0b01010111); //W
writechar(0b01001100); //L
writechar(0b01010010); //R
writechar(0b01001111); //O
writechar(0b00010000); //Space
shift(5);
_delay_ms(5000);
}
return 0;
}
void writechar(unsigned char data)
{
PORTA=data;
PORTC=0b11000000;
PORTC=0b01000000;
_delay_ms(30);
}
void shift(int steps) //Gör saker
{
int n=0;
while(n<steps)
{
PORTA=0b00011100; //Shift display right
PORTC=0b10000000;
PORTC=0b00000000;
_delay_ms(30);
n+=1;
}
int m=0;
while(m<(2*steps))
{
PORTA=0b00010000; //Shift cursor left
PORTC=0b10000000;
PORTC=0b00000000;
_delay_ms(30);
m+=1;
}
}