Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help with this PicBasic program!!!

Status
Not open for further replies.

rosecatherine

Newbie level 3
Joined
Feb 5, 2008
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
what to do if you ask for an input?

the port i am using is PORTC.0?

will i just do this:

if PORTC.0 = 1 then
high PORTD.1
endif

?


is there anything more specific like it waits for the user to give the input?
thanks a lot! :)
 

looks like there's a problem with your compiler/include file. Did you ever compiled a program before with your recent software and settings?
 

I'll assume you want to use a push-button for a user to press... look for the 'button' instruction - it 'de-bounces' a switch which is usually needed for a nice clean input from an electrical connection made via puch button switches.

' BUTTON Command
' - taken from https://www.microengineeringlabs.com/resources/samples.htm
' Demonstate BUTTON command. Prints working variable (in this case B0) to
' show how auto-repeat works. Prints "PRESS" when button is pressed or
' repeated.

Symbol SO = 0 ' Serial Output
Symbol B = 5 ' Button Input

B0 = 0 ' Zero Button Working Buffer
Loop: Button B,1,10,5,B0,0,Skip ' Check Button (Skip if Not Pressed)
Serout 0,N2400,("Press",13,10) ' Indicate Button Pressed
Skip: Serout 0,N2400,(#B0,13,10) ' Show Working Variable
Pause 100 ' Visual Pause
Goto Loop ' Forever


Other wise... this should 'wait' for input if you are electrically de-bouncing the button/switch...

while PORTC.0 = 1
high PORTD.1
wend

But may depend on what version of picbasic you are using... (is 'while' a legitimate command?)

If not..try...

Loop: if PORTC.0 = 1 then turnon
if PORTC.0 = 0 then notyet
turnon:
high PORTD.1
goto exitloop
notyet: goto Loop

exitloop:

#more code here
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top