basic question reading inputs
Ell
Posts: 2
I am sorry for posting such a basic question but, I have been trying to read a switch closing and turning on an LED when it does. I am not new to programing pics,but I am·new to the spin language,·but I am no expert either.It would seem like it would be a simple if..then statement. If someone could show me a simple program displaying how the if statement works I would be indebted. This is what I had. I turned on the block indicators I can not think of what I would be doing wrong.
{switch}
pub sw
dira[noparse][[/noparse]0]~~
··
· repeat
···if ina[noparse][[/noparse]1] == 1
···· outa[noparse][[/noparse]0]~~
·
{switch}
pub sw
dira[noparse][[/noparse]0]~~
··
· repeat
···if ina[noparse][[/noparse]1] == 1
···· outa[noparse][[/noparse]0]~~
·
Comments
[/code][/size]
Try the PEkit labs, you'll find a lot of information there.
http://forums.parallax.com/showthread.php?p=617192
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Post Edited (Oldbitcollector) : 10/15/2008 3:46:28 AM GMT
If you want to get tricky, you can configure one of the counters to function as a simple·logic inverter gate with a 12.5ns propagation delay that·won't require any processor overhead.· That way you are free to do other things in code rather than using an IF/THEN statement to set the pin state.
Note: you only need to call "PUB Inverter" once in your code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Thanks for the enlightenment