Shop OBEX P1 Docs P2 Docs Learn Events
Whats wrong with this code? — Parallax Forums

Whats wrong with this code?

jaegjaeg Posts: 156
edited 2005-10-07 17:13 in BASIC Stamp
I just started with the basic stamp 1 and I decided to make a simple little circuit that lights up a led when the senser detects what it is suposed to detect.· Right now I have it hooked up to a cds cell for the sensor.· But it is not working.· I now the setup is ok but the code doesn't seem to go to the section.·
Here is the code:
' {$STAMP BS1}
' {$PBASIC 1.0}
main:
DEBUG "main"
· IF PIN1 =·1 THEN led
GOTO main
led:
DEBUG "led"
PULSOUT 0, 100
GOTO main

Why is it not working?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-06 23:07
    A CdS cell is not a HIGH/LOW or 1/0 type sensor.· You would need to build a voltage divider or use the POT command to properly read the photocell to get a 1 or 0 on the input pin.· It's not as simple as connecting it and getting a 1 or 0.· How is it that you have it connected to the I/O pin?· Where do both ends connect?


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • jaegjaeg Posts: 156
    edited 2005-10-07 16:46
    One end is connected to the vss and the other connected to the P1.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-07 17:13
    That definately won't work.· You need to build a divider at minimum for that to work.· Or you can use the POT command with the appropriate circuitry (Listed in the Help file).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.