-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflash_an_LED.c
More file actions
44 lines (33 loc) · 1.12 KB
/
flash_an_LED.c
File metadata and controls
44 lines (33 loc) · 1.12 KB
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
// #include <LPC21xx.h> // Header for LPC2129 registers
// #include "delay.h"
// #define OPIN 0 // Set P0.6 as output
// int main(void) {
// unsigned int i;
// IODIR0 = (31 << OPIN);
// for(i = 0; i < 5; i++) {
// IOSET0 = (1 << i); // Turn ON LED
// delay_ms(1000); // Delay 200 milli seconds
// IOCLR0 = (1 << i); // Turn OFF LED
// delay_ms(1000); // Delay 200 milli seconds
// }
// // Stop blinking (LED remains ON)
// IOSET0 = (1 << i);
// while(1); // End of program
// }
//Flash an LED connected to any port line at the rate of 1 second for 10 times and stop.
#include <LPC21xx.h> // Header for LPC2129 registers
#include "delay.h"
// #define OPIN 0 // Set P0.6 as output
int main(void) {
unsigned int i;
IODIR0 = 1023;
for(i = 0; i < 10; i++) {
IOSET0 = (1 << i); // Turn ON LED
delay_ms(300); // Delay 200 milli seconds
IOCLR0 = (1 << i); // Turn OFF LED
delay_ms(300); // Delay 200 milli seconds
}
// Stop blinking (LED remains ON)
//IOSET0 = (1 << i);
while(1); // End of program
}