indio_19gen
Newbie level 3
- Joined
- Dec 24, 2012
- Messages
- 4
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,307
Good day! Can anyone help me to solve this problems. I have already the code in c language and I would like to use sensor but i don't know how to code it. When sensor is activated means is ON the motor will stop then if sensor is OFF the motor is activated. And also, i want to use LED to indicates the motor directions. I have attached my simulation here. Can you please help me about this. Thanks
this is the link of simulation:
https://obrazki.elektroda.pl/6434967200_1356351832.jpg
here's the code that i have.
this is the link of simulation:
https://obrazki.elektroda.pl/6434967200_1356351832.jpg
here's the code that i have.
Code:
#include<16F877A.h>
#fuses HS, NOPUT, NOLVP
#use delay(clock=20Hz)
void main()
{
while(true)
{
//-------------------------------for motor operation
if(!input(PIN_D0))//---------microswitch
{
//-------------------------------switch for reversing
output_high(PIN_B2);//----clockwise mode
if(!input(PIN_D1))
{
output_high(PIN_B0);
output_low(PIN_B1);
}
else if(!input(PIN_D2))//-----counter clockwise mode
{
output_high(PIN_B1);
output_low(PIN_B0);
}
}
else if(input(PIN_D0))
{
output_low(PIN_B2);
}
}
}
Last edited by a moderator: