'counting' switches

Hi all!

I have an RF board attached to my arduino that gives me a changing digital output as long as a button is pressed on the remote. So as long as the button is pressed, the voltage changes to be either 0.1 or 5.0 V about every other 100-200 ms (the rate seems to vary with signal strength). When I stop pressing the button while the output on the pin is still HIGH, it stays HIGH. For now I'm just using these few lines of code to give me the ability to switch an LED on and off.

For now, I'm using this code, it's crude and simple but it works:

if (btnAstate != lastBtnStateA) {

    if (mode == 1){
    digitalWrite(ledPIN, HIGH);
    mode = 2;
    }
    else if (mode == 2){
    digitalWrite(ledPIN, LOW); 
    mode = 1;
    }
    
   lastBtnStateA = btnAstate;
   delay(500);  
  }

Now what is cool about the changing output is that I get more or less accurate information about how long the button is pressed. I'm not using that at all, which is a waste. Overall I have four buttons to control two TLC5940 PWM chips to which I've attached 30 LEDs in a 5*6 rectangle. It's late at night and I'm happy that I've made it so far. Maybe someone has a little coded inspiration about how to make better use of this remote? Only switching between a few modes is SO boring...

Greetz Milarepa

Hi,

How about count the 'pulses' each time, so you can reliably discriminate between a long and a short button press, and the time between presses.

Then you COULD decode Morse Code and send 26 states :)

Seriously, my home control system has about 20 commands and all there is for control is one button.

T is Temperature, W is Weather Info, O is OutSide Lights etc etc....

Amazing how fast my kids learned some Morse ...

I’m confused.
What is a home control system.
What does it have to do with morse code?

smeezekitty: [quote author=Terry King link=topic=51741.msg368938#msg368938 date=1297314507] ... How about count the 'pulses' each time, so you can reliably discriminate between a long and a short button press, and the time between presses. Then you COULD decode Morse Code and send 26 states :)

I'm confused. What is a home control system. What does it have to do with morse code? [/quote] Home control AKA Home Automation: Monitoring and controlling many of the functions in a home, including temperature and environment variables, lighting and energy management, etc. etc. A few links: http://tech.groups.yahoo.com/group/arduinohome/ http://www.instructables.com/id/Arduino-Home-automation/ http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1284455681 http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1278347111/0

Years ago when the only easily-available human interfaces were PC's with DOS, I tried to make the simplest possible human interface to the home control system I was building. There were lots of machine interface and sensor things.

So I got down to:

  • Human Input: 1 button (several in parallel around the house) (decodes Morse)
  • Human Output: Audio from a Voice Synthesizer. A couple of inobtrusive speakers.

Works good. At night in bed in the dark I can reach up, find the button, and turn off the outside lights "O" and check the inside and outside temperatures : "W" , with my eyes closed.

...works for me...

Now I just need to replace my old IBM AT with a couple Arduinos.