I am doing the programming of some step by step motors, but I have a doubt in which I want to control the delay with a potentiometer, but I have not been able to do it since the resolution values are not well defined to work with the potentiometer
I'm not familiar with that compiler but I'm assuming that the pot value is remapped to 0 to 500. If so can you change it to delay uS?
You also need to move the pot read inside the while loop and make sure it's reading the ADC.
Mike.
BTW, when posting code use code tags so it keeps it's formatting,
Code:
void main(){
int POT= (input (PIN_A1), 0, 1023, 0, 500); ;
set_tris_B(0b00000000);
while (1){
if (input (PIN_A0)== 1){
output_B(0b00000001);
delay_ms(POT);
output_B(0b00000010);
delay_ms(POT);
output_B(0b00000100);
delay_ms(POT);
output_B(0b00001000);
delay_ms(POT);
}
}
}
Ian, I'm not familiar with that compiler (or don't recognize it) but it looks like the line if (input (PIN_A0)== 1){ is reading A0 as digital. So the delay will be either 0mS or 500mS.
Also the analogue isn't read in the while loop, which makes the variable pot superfluous... In fact it isn't read at all..
I have just looked at the documentation.. CCS C compiler and the delay_ms(); does indeed take a variable..