-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLED_Pattern_Sequence.c
More file actions
51 lines (37 loc) · 1001 Bytes
/
LED_Pattern_Sequence.c
File metadata and controls
51 lines (37 loc) · 1001 Bytes
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
// This code sequentially sets PORTD to specific binary values at different moments with a 100ms delay between each change,
// creating a pattern of LED states that resembles a visual effect.
#include <mega32.h>
#include <delay.h>
void main(void) {
// Set the data direction register for PORTA as output
DDRD = 0xFF;
while (1) {
// Moment 1
PORTD = 0b10000001;
delay_ms(100);
// Moment 2
PORTD = 0b01000010;
delay_ms(100);
// Moment 3
PORTD = 0b00100100;
delay_ms(100);
// Moment 4
PORTD = 0b00011000;
delay_ms(100);
// Moment 5
PORTD = 0b00000000;
delay_ms(100);
// Moment 6
PORTD = 0b00011000;
delay_ms(100);
// Moment 7
PORTD = 0b00100100;
delay_ms(100);
// Moment 8
PORTD = 0b01000010;
delay_ms(100);
// Moment 9
PORTD = 0b10000001;
delay_ms(100);
}
}