need guidance
Jose AAG
Posts: 5
I have programed a few PlCs but now my boss wants to create our own controller, can some one help me write a little program just an input and an output ( when the input is made the output should make)· I'm using a Stamp1 project board. I'v been reading for two days and have tried a few of the included samples but since I have no experience in basic is a little dificult. Thanks in advance for any help.
Comments
For example, if you press a button (input), an LED will blink (output)...
Thanks
Wait:
if Pin0 = 1 then Wait
Blink:
Pin4 = 0
pause 250
Pin4 = 1
pause 250
if Pin0 = 1 then Blink
goto Wait
Dir0 = 0
Dir4 = 1
I don't have BS1 experience, but can tell you that starting off with a BS2 would be much easier. It uses improved PBasic syntax, and there is more info available.
Take a look at the "What's a Microcontroller" manual, which can be downloaded for free. Chapter three describes doing what you are trying to do, the caveat being that the code is written for the BS2, not the BS1.
A good way to get started with a BS2 is the Summer Special, also known as the RadioShack "What's a Microcontroller" Kit.
But if you are limited to the BS1, keep posting, there are plenty of people here than can help.
I suspect you need a pull-up resistor on P0, don't you?
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
thanks for the fast responses guys.
You can also have a pull-down resistor with the switch connected from the pin to Vcc, but most sensors and switches are meant to connect a signal line to ground since the ground can also serve as a shield.
Vss to Sw to P0
Vdd to 10k to P0
LED Short leg to P4, long leg to 470 ohm- to Vdd and apply the following code
Dir0 = 0
Dir4 = 1
Wait:
if Pin0 = 1 then Wait
Blink:
Pin4 = 0
pause 250
Pin4 = 1
pause 250
if Pin0 = 1 then Blink
goto Wait
As soon as I power up LED blink but when sw makes (closes) Led stops blinking
Post Edited (Jose AAG) : 6/22/2006 9:52:36 PM GMT
'zero' to Pin0. When you press it, it 'opens', and lets the pin float.
So, change the "IF Pin0 = 1" to "IF Pin0 = 0".
Thanks to all of you, I'll keep on playing with it.