Hy, i am facing problem in controlling dc motor.I wants when i will apply 1 at p1^1 then 2 motor which is connected at p2^0 and p2^1 and at p2^2 and p2^3 moves. otherwise remain off. Plz guide me. how can i do??????????????? my programming. plz check it
Code C - [expand] |
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
| #include <reg51.h>
sbit rotate = P1^0;
sbit square = P1^1;
sbit mtr_0 = P2^0;
sbit mtr_1 = P2^1;
sbit mtr_2 = P2^2;
sbit mtr_3 = P2^3;
void timer(int msec)
{
int i;
for(i=0;i<msec;i++)
{
TMOD=0x20;
TH1=0xFF;
TL1=0xD1;
TR1=1;
while(TF1==0);
TF1=0;
TR1=0;
}
}
void main()
{
mtr_0=0;
mtr_1=0;
mtr_2=0;
mtr_3=0;
if(square==1)
{
mtr_2=0;
mtr_3=1;
mtr_0=1;
mtr_1=0;
}
} |