Code:IF (DIP = 0) AND (BUT = 1) THEN SOMETHING IF (DIP = 1) AND (BUT = 1) THEN SOMETHING ELSE
Code:IF (DIP = 0) AND (BUT = 1) THEN SOMETHING IF (DIP = 1) AND (BUT = 1) THEN SOMETHING ELSE
Dave
Always wear safety glasses while programming.
Not as elegant as Dave's... but why do it in one line when you can do it in ten (Ski is not allowed to answer that one)...
Code:PushButton var PortB.0 ' Low when Pressed DIPSwitch var PortB.1 ' Low when ON LED var PortB.2 TRISB=%00000011 Low LED ' Start with LED OFF Loop: If PushButton=0 then ' Check for Button Press If DIPSwitch=0 then ' Check for Options High LED ' Turn ON LED with Button Press... While PushButton=0:Wend ' Wait here as long as Button pressed Low LED ' then turn OFF LED else Toggle LED ' Toggle LED at each Button Press While PushButton=0:Wend ' Wait here until finger released from Button endif endif Goto Loop End
Thanks a lot..Code:PushButton var PortB.0 ' Low when Pressed DIPSwitch var PortB.1 ' Low when ON LED var PortB.2 TRISB=%00000011 Low LED ' Start with LED OFF Loop: If PushButton=0 then ' Check for Button Press If DIPSwitch=0 then ' Check for Options High LED ' Turn ON LED with Button Press... While PushButton=0:Wend ' Wait here as long as Button pressed Low LED ' then turn OFF LED else Toggle LED ' Toggle LED at each Button Press While PushButton=0:Wend ' Wait here until finger released from Button endif endif Goto Loop End
there are 6outputs and 8inputs available in my project. as per above explanation need 12 input ports to enable all.(6for dip and 6 for push buttons) is there any way that to create a dip switch combination, with 2 dip switches..
Regards.
Put one dip on a port. Then read the whole PORT into a variable.
Read this thread, post #2Code:dip1=PORTB dip2=PORTC
http://www.picbasic.co.uk/forum/show...ight=read+port
Dave
Always wear safety glasses while programming.
Thank you. I tried to understand from the PBP manual but i couldnt succeed. could you pls give some code Example.
Regards.
Hi this program is great that Mel has writen can we use the same program but soon as the button is pressed led go high for 500 / 1/2 second then PWM 50 duty and 5KHz and then then pwm stop when button is released?
i have the program working but the PWM hangs on after the button is off
PushButton var PortA.1 ' Low when Pressed
DIPSwitch var PortA.1 ' Low when ON
LED var PortB.0
TRISA=%1111
TRISA=%0000
Low LED ' Start with LED OFF
Loop: If PushButton=0 then ' Check for Button Press
If DIPSwitch=0 then ' Check for Options
High LED ' Turn ON LED with Button Press...
PAUSE 500
PWM 0,50,500
While PushButton=0:Wend
' Wait here as long as Button pressed
Low LED ' then turn OFF LED
else
Toggle LED ' Toggle LED at each Button Press
While PushButton=0:Wend
' Wait here until fingerreleased from Button
endif
endif
Goto Loop
End
Bookmarks