[PIC] need code for dcmotor control with 16f877a in PIC C compiler

Status
Not open for further replies.

kathi saiprathap reddy

Newbie level 3
Joined
Nov 6, 2014
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
26
i tried this code in pic c compiler but it shows an error with motor.c can any one help me out of this 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <16f877a.h> 
#use delay(clock=20M) 
#fuses NOWDT,PROTECT,HS 
#include <motor.c> 
 
 
Void main() 
{ 
unsigned int i, value, temp,gas; 
output_high(pin_d2); 
output_high(pin_d3); 
delay_ms(500); 
output_low(pin_d2); 
output_low(pin_d3); 
delay_ms(500); 
output_high(pin_d2); 
output_high(pin_d3); 
delay_ms(500); 
output_low(pin_d2); 
output_low(pin_d3); 
 
    
while(1) 
{ 
 
      for(i=0;i<=10;i++) 
      { 
       set_adc_channel( 0 ); 
        
      delay_ms(50); 
      
      value = read_adc(); 
      
      temp = value*2.5; 
      
      
 
      motor_forward(); 
      output_high(pin_d3); 
      output_low(pin_d2); 
      output_low(pin_d7); 
      delay_ms(500); 
      if(input(pin_b0)) 
      { 
      motor_right(); 
      output_high(pin_d2); 
      output_low(pin_d3); 
      output_low(pin_d7); 
      } 
      else if (temp > 50 ) 
      { 
      output_high(pin_d7); 
      output_high(pin_d2); 
      }      
      else 
      { 
      output_low(pin_d2); 
      output_low(pin_d7); 
      } 
} 
}

please tell me how to write a code for motor in PIC c compiler.
 
Last edited by a moderator:

you don't appear to have included the code for motor.c

what compiler are you using?

note that
Code:
Void main()
should be
Code:
int main(void)
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…