Hello Everybody,
I hope someone will help me in resolving my problem. I am new to Microcontroller and Mikroc. My project details in short is given as below.
1. I am using PIC16F886 for this project.
2. I have setup 2 ADC on PORT A0 and A1 for input.
3. I have setup a Button(Push to on Switch) on PORT A1.
4. I have setup LCD 2 x 16 on PORT C.
5. Finally I am using 8Mhz internal osc.
Now I read 2 values from A0 and A1 in my while loop. Now what exactly I want is when I press switch this loop should stop working and again when I press the same for second time the loop should start working.
below is the code :
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
| while(1)
{
unsigned int v,vp,ip,i;
char *volt = "00.00";
char *current = "0.000";
char *res = "0.000";
v = ADC_Read(0);
i = ADC_Read(1);
i = ((i*4.89)/0.33); //0.47;
v = ((v*4.89)/27)*254;
if(v!=vp || i!=ip || e!=r )
Lcd_Cmd(_LCD_CLEAR);
vp = v;
ip = i;
volt[0] = look(v/10000);
volt[1] = look((v/1000)%10);
volt[3] = look((v/100)%10);
volt[4] = look((v/10)%10);
Lcd_Out(1,1,"Volt=");
Lcd_Out(1,10,volt);
Lcd_Out(1,18,"V");
current[0] = look((i/1000)%10);
current[2] = look((i/100)%10);
current[3] = look((i/10)%10);
current[4] = look(i %10);
Lcd_Out(2,1,"Curr=");
Lcd_Out(2,10,current);
Lcd_Out(2,18,"A");
} |
please help me in using switch to start and stop this loop.
Thankyou all in advance.