
Originally Posted by
Bruce
Been there - done that - just spank yourself, take notes & move on...

I did 
Hi again !
I would like your opinions guys in terms of "state of the art" way to write a picbasic pro program
I am getting inputs from an encoder, I have 12 positions possible, therefore 12 values. here is an example of my code for 2 values. I was wondering if the use of "Case" would be a better idea, that way if I decide to turn off my "switch" my program stops immediatly and is not finishing its loop before seeing that the switch's value changed.
Code:
encoderstate1 var Byte
duty var Word
Main:
encoderstate1 = PORTA
If switch = 1 Then
If encoderstate = 0 Then
GoSub GetADC
GoSub SetPWM
OVDCOND = %00100010 'Q4 (PWM5) and Q10 (PWM1)
PORTC = %00000011 'Q1 and Q7 ON
EndIf
If encoderstate1 = 1 Then
GoSub GetADC
GoSub SetPWM
OVDCOND = %00000110
PORTC = %00001100
EndIf
GoTo Main
Getadc is my subroutine for my pot and pwm to adjust the duty cycle regarding the value of the pot.
Suggestions ?
Bookmarks