imedx86
Newbie level 2
- Joined
- Jun 3, 2015
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 10
that is the pattern and the code to vary the speed of a stepper motor with push-button how do this function with ADC thank you
Code:
char a,b;
void interrupt()
{
if(intcon.rbif)
{
if(portb.b4==0) {a++;}
if(portb.b5==0) {a--;}
if(a==10) a=9;
if(a==0) a=1;
}
intcon.rbif=0;
}
speed();void speed()
{
for(b=0;b<a;b++)
delay_ms(50);
}
TRISB=0xF0;
PORTB=0;
INTCON=0b10101000;
a=1;
for(;;)
{
while(portc.b0==0)
{
portb= 0x08; speed();
portb= 0x0C; speed();
portb= 0x04; speed();
portb= 0x06; speed();
portb= 0x02; speed();
portb= 0x03; speed();
portb= 0x01; speed();
portb= 0x09; speed();
}
while(portc.b1==0)
{
portb= 0x09; speed();
portb= 0x01; speed();
portb= 0x03; speed();
portb= 0x02; speed();
portb= 0x06; speed();
portb= 0x04; speed();
portb= 0x0C; speed();
portb= 0x08; speed();
}}}
Last edited: