Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

comparing bits in Swordfish

Status
Not open for further replies.

MrDEB

Well-Known Member
Before I get this all screwed up, I need to compare button presses.
Have 5 lighted tactile switches that are lit in random order.
then
the player must depress the switches in same order.
was thinking of using string compare but is it the preferred method? contemplated turn on Led1 then see if the corresponding switch is pressed. Very similar to the game Simon.
Library - String
function Compare (pStrA, pStrB as string) as shortint
 
was thinking of using string compare but is it the preferred method?
Only if your switch inputs are declared as strings, which I highly doubt.

Create an array of five bytes to hold the led/switch number and fill it in as you light them,
so you end up with something like:
Code:
dim order(5) as byte

order(0) = LED2
order(1) = LED4
order(2) = LED5
order(3) = LED1
order(4) = LED3
Then, as the user presses switches five times (0-4) see if the current switch press matches what's in the array.
You could do the same with 5 variables (call them 'order1'-'order5'), which is probably what you'll end up with on page 43
 
Status
Not open for further replies.

Latest threads

Back
Top