Using an LED as a button
piguy101
Posts: 248
Using the Mims effect of LEDs, I programmed the Propeller to use an LED as a button. The LED turns on when it is touched and off when it is touched again. Ignore all the other circuitry as it is from a game of simon that I didn't want to tear apart. Currently, the "button" is flaky and only responds ~80% of the time. Because there are no moving parts like a conventional button, this will never wear out, but when I turn the light in the room on and off, the button is activated. Sorry, the code isn't commented and is probably impossible to understand my logic, but there is a schematic.
{{LED Button Uses the Mims effect to use an LED as a button without any moving parts like a button. By sensing sudden changes in light, the Propeller detects a finger on the LED and illuminates the LED until the LED is touched again. The LED functions as a photodiode and a counter module measures the time for the R/C circuit to fall. No capacitor is needed in this case as the solderless breadboard provides enough stray capacitance. 47Ω P11───┳────┳────P10 │ │ └────┘ 10MΩ }} con _clkmode=xtal1+pll16x _xinfreq=5000000 pub main | time1, time2, index, power ctra[30..26]:=000 ctra[5..0]:=10 frqa:=1 dira[11]~~ dira[16]~~ repeat 10 dira[10]:=outa[10]:=1 waitcnt(clkfreq/100000+cnt) phsa~ dira[10]~ waitcnt(clkfreq/1000+cnt) time2+=phsa time2/=10 repeat repeat 10 dira[10]:=outa[10]:=1 waitcnt(clkfreq/100000+cnt) phsa~ dira[10]~ waitcnt(clkfreq/1000+cnt) time1+=phsa time1/=10 if ||(time1-time2)>30 index+=1 if index//2==1 if power==0 power:=1 elseif power==1 power:=0 waitcnt(clkfreq/10+cnt) time2:=0 if power==0 dira[10]:=dira[11]:=outa[10]:=outa[11]:=0 elseif power==1 dira[10]:=dira[11]:=outa[11]:=1 outa[10]:=0 waitcnt(clkfreq/1000+cnt) dira[10]:=outa[10]:=outa[11]:=0 dira[11]:=1 repeat 10 dira[10]:=outa[10]:=1 waitcnt(clkfreq/100000+cnt) phsa~ dira[10]~ waitcnt(clkfreq/1000+cnt) time2+=phsa time2/=10 if ||(time1-time2)>30 index+=1 if index//2==1 if power==0 power:=1 elseif power==1 power:=0 waitcnt(clkfreq/10+cnt) time1:=0 if power==0 dira[10]:=dira[11]:=outa[10]:=outa[11]:=0 elseif power==1 dira[10]:=dira[11]:=outa[11]:=1 outa[10]:=0 waitcnt(clkfreq/1000+cnt) dira[10]:=outa[10]:=outa[11]:=0 dira[11]:=1
Comments
I haven't ever tried this myself. I really like the idea of the button never wearing out. It seems like it's also a great way of having a water proof button.
The detection ability and reliability of the "LED BUTTON" completely depends on the wavelength of led you choose, ALONG with the overhead lighting you have in the room.
The only way to defeat environment lighting is to provide your own.
In this image, the ccfl tube is mounted directly above the leds for absolute operation in all environments.
The concept that mimms discovered is nothing more than a tripline using an led as detector. A led as emitter, and the same led as detector. This ensures same wavelength.
Concept could be used with other wavelength, i.e. uv, ir, etc... Some leds are better detectors than others.
Mini RED leds seem to work best, along with an incandescent.
The led on the very left side is the mini.