Newbie question re multiple key inputs

Teazle

New Member
My very first project so go easy on me!

I'm trying to make a controller for use with a fog horn on a boat. The important signals are various sequences of long and short sounds which are then repeated every two minutes for as long as necessary.

There are also a number of sequences which are used "one off" for instance to say "I'm turning left", "I'm reversing" etc. etc. (Yes, I know I'm not using very nautical language!). To be honest these don't really need to be programmed into the controller but I'm going to do it anyhow.

The main programme is pretty simple....it's just a number of calls to subroutines, with pauses and "high" "low" commands as appropriate. My problem is that I want to control this using just 5 switches (It suits what I want to do and it also by coincidence suits the chip I am using). To do this I need to be able to use each switch on it's own to initiate a subroutine, and I then need to use a combination of switches to initiate other routines. There's no problem with the first bit.......I've just used an "if....then" command. However, to use two keys I've tried using "If switch 1 and switch 2...then". Inevitably this doesn't work as it is impossible to press both switches simultaneously and the wrong routine is called before it then goes onto the correct routine.

I suspect that there is a very simple solution but I can't find it. I've looked at the manual and wonder if "button" would do it but the explanation of this command has me completely flummoxed.

I'm using a PICAXE 18X for no other reason than that is what came with my board!

Any help gratefully received!:)
 

graynomad

Senior Member
I think most systems that do this have a delay whereby no action is taken until the value you read for all switches is stable for say 1 sec. That way you can sync your fingers, but of course even when one button is pressed there will still be a delay.

This is basically a really long debounce.

Once you have the value you can use a select to determine which function to call.
 
Last edited:

hippy

Ex-Staff (retired)
Welcome to the PICAXE forum.

Another solution is to have one button as a separate 'shift key' and the other four to indicate what to sound; that gives eight sounds. You can also use pressing that button by itself to cancel any repeating sound that's being given out.

The first step is to define how many sounds you need and how you want to use the butons to access them. Get the ergonomics and operation defined then write the code to implement that.
 
Top