Skip to content

Commit 09c9cc6

Browse files
authored
Add files via upload
1 parent 099f693 commit 09c9cc6

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// this is a c code for project on Dc motor and LED blinking using Pulse Width Modulation
2+
3+
#include<reg52.h>
4+
5+
void ms_delay(unsigned int time);
6+
7+
void main()
8+
{
9+
int x;
10+
11+
while(1)
12+
{
13+
for(x=0;x<=200;x++)
14+
{
15+
P1=0x0ff; // on led
16+
P3=(0x01<<5); // on motor(left shift by 5 places
17+
ms_delay(1); // 1s delay
18+
P1 =0x00; // off led
19+
P3 = 0x00; // off motor
20+
ms_delay(9);
21+
22+
}
23+
24+
for(x=0;x<=200;x++)
25+
{
26+
P1=0x0ff; // on led
27+
P3=(0x01<<5); // motor on
28+
ms_delay(1); // 1s delay
29+
P1 =0x00; // off led
30+
P3 = 0x00; // off motor
31+
ms_delay(5);
32+
}
33+
34+
for(x=0;x<=200;x++)
35+
{
36+
P1=0x0ff; // on led
37+
P3=(0x01<<5); // motor on
38+
ms_delay(9); // 1s delay
39+
P1 =0x00; // off led
40+
P3 = 0x00; // off motor
41+
ms_delay(1);
42+
}
43+
}
44+
}
45+
46+
void ms_delay(unsigned int time)
47+
{
48+
unsigned int i,j;
49+
// time X 1ms
50+
for(i=0;i<time;i++)
51+
{
52+
for(j=0;j<113;j++);
53+
54+
}
55+
56+
}
57+

PWM project/PWM_ckt.png

125 KB
Loading

PWM project/outputs.png

681 KB
Loading

0 commit comments

Comments
 (0)