lipming
Newbie level 5
Hi, I'm using MikroC for this project and I have some problem.
I just want to turn the servo motor +90 degree when a button is pushed ( logic 1 ) and when button release ( logic 0) the motor goes back to 0 degree.
Previously I manage to achieve that but the motor in the servo keeps on running because the program is always in a loop. So I decide to modify it. So far no luck at all.
Can some one take a look and tell me whats wrong with my coding? Thanks in advance.
I just want to turn the servo motor +90 degree when a button is pushed ( logic 1 ) and when button release ( logic 0) the motor goes back to 0 degree.
Previously I manage to achieve that but the motor in the servo keeps on running because the program is always in a loop. So I decide to modify it. So far no luck at all.
Can some one take a look and tell me whats wrong with my coding? Thanks in advance.
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 unsigned int temp_res; oldstate; i; void main() { TRISA = 0xFF; TRISD = 0b00000000; PORTD= 0b00000000; do { temp_res = ADC_Read(0); if (temp_res==0) { goto close; } if (temp_res>0) { goto open; } }while(1); open: PORTD=0b00000001; delay_us(1500); PORTD=0b00000000; delay_us(1000); close : PORTD=0b00000001; delay_us(2000); PORTD=0b00000000; delay_us(2000); }
Last edited by a moderator: