EmbDev.net

Forum: µC & Digital Electronics Digital push-button


von Konstantinos (Guest)


Rate this post
useful
not useful
Dear μController community,

I am a complete beginner in the field so my question might seem a bit 
naive.
In short I need to implement a circuit switch that will change state 
(ON/OFF) every time a short pulse is sent (trigger). In effect it is a 
digital push-button. For instance on a first trigger the circuit open, 
on the 2nd will close..etc..

Do you have any simple solution to this? Is it something easy to 
implement with a μcontroller? I am currently looking for the simplest, 
least time consuming solution so if there is another way other than 
programming ICs please let me know.

Sincerely,
Konstantinos

von MaWin (Guest)


Rate this post
useful
not useful
If the circuit does always have power,
than a simple flip flop does
1
  +-----------+  CD4011
2
  |           |                 
3
  |       +---)----------------+
4
  |       |   |                |
5
  |       +--|>o--10k--+--|>o--+-- on/off
6
  | +         |        |       |  
7
Battery       |        |       1M
8
  | -         |        |   _   | 
9
  |           |        +--o o--+ 
10
  |           |                | 
11
  |           |              100nF
12
  |           |                |
13
  +-----------+----------------+

If you loose power, there are specialized
single bit non volatile state saver memory chips like
FM1105B, FM1106, FM1107, FM1110, FM1114 (RamTrom FERAM)

Of course you can program it also into a small micro controller
that has an EEPROM to save state during power loss.
For the Arduino programming environment
1
char key=0, lastkey=0, savedkey;
2
const char inputpin = 1;
3
const char outputpin = 2;
4
5
void setup()
6
{
7
    pinMode(inputpin,INPUT); 
8
}
9
10
void loop()
11
{
12
  while(1)
13
  {
14
    key=digitalRead(inputpin);
15
    if(key==1&&lastkey==0)
16
    {
17
      savedkey=EEPROM.read(11);
18
      savedkey=1savedkey;
19
      EEPROM.write(11, savedkey);
20
      digitalWrite(outputpin,savedkey)
21
    }
22
    lastkey=key;
23
    delay(10);
24
  }
25
}
So this is rather simple.

: Edited by Admin
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.