Solenoids and the Debug Menu
calvin777
Posts: 2
Hello all. This is my first post here, so bear with me if any of this is incredibly trivial. For a school assignment I have to use the BASIC Stamp with various actuators. As an introduction to all of this, the instructors have us performing basic tasks, like turning on a DC motor for 5 seconds and turning off, then programming it so the motor only turns on when a switch is pressed, etc.
One of these tasks is to activate a solenoid for a set length of time when a switch is pressed, then release it and repeatedly check for the closed switch. I have got this working, but strangely, only when I include the debug line. I can't figure out why this would be necessary, and it's driving me batty. Here is the (short) code from my program.
If I comment out the "DEBUG ? IN4" line, the program ceases to work properly. The solenoid will only activate if the switch is closed at the time I compile the code, and then it doesn't repeatedly check to see if the switch is closed again after 2 seconds.
Any veterans want to help out a rookie here? Thanks.
One of these tasks is to activate a solenoid for a set length of time when a switch is pressed, then release it and repeatedly check for the closed switch. I have got this working, but strangely, only when I include the debug line. I can't figure out why this would be necessary, and it's driving me batty. Here is the (short) code from my program.
' {$STAMP BS2p} ' {$PBASIC 2.5} DO DEBUG ? IN4 IF IN4=1 THEN 'Check the state of switch in pin 4. If closed, then HIGH 11 'Activate solenoid on pin 11 PAUSE 2000 'Pause 2 seconds LOW 11 'deactivate solenoid on pin 11 ENDIF LOOP 'repeat loop END
If I comment out the "DEBUG ? IN4" line, the program ceases to work properly. The solenoid will only activate if the switch is closed at the time I compile the code, and then it doesn't repeatedly check to see if the switch is closed again after 2 seconds.
Any veterans want to help out a rookie here? Thanks.
Comments
With the serial cable plugged in, the DEBUG line is required to get the code to run as desired. However, if the serial cable is removed, then the DEBUG line must also be removed, or else the solenoid will only activate once, no matter how many times the switch is closed.
Your thoughts?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support