• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

BASIC STAMP : How to input bits into an accumilator

Lets say I have two push button switches connected to the input port of a basic stamp. What I want to know is how to write a simple program to input a "1" when the 1st button is press and a "0" when the sexond button is pressed. I'll have the the 5v connected to both switches and a not gate connected to the second.
0
940775
Asked:
940775
  • 2
1 Solution
 
LRHGuyCommented:
If I understand the problem, you want to use ONE input port, which to the stamp is either a 1 or a 0, and connect two buttons to it to detect either a 1 or a 0 .... it doesn't seem possible.

You'd need a tri-state input for that...which would be "seen" as a 1 a 0 or "not a 1 or 0" as the third state. I don't believe the stamp can do that.

Now it you're using two input ports, no problem!
0
 
940775Author Commented:
OK LRHGuy, lets use two input ports. How would you write the code  (just an example)?
0
 
LRHGuyCommented:
With the stamp it's a simple process:

KEEPGOING:
 IF PIN1=1 THEN DOONE
 IF PIN2=0 THEN DOTWO
 GOTO KEEPGOING

DOONE:
  ; handle button
  GOTO KEEPGOING

DOTWO
  ; handle button
  GOTO KEEPGOING

Put whatever you need to do in the DOONE/DOTWO sections.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now