Colour-key -- yet another use case

A project log for lua-stick

"lua-stick" is a development-tool-free embedded hardware platform. All you need is a text editor to connect virtually anything to your PC.

magnustronmagnustron 08/26/2014 at 18:580 Comments

This might be quite useful. A key that can be programmed to change colours when turning and enter a colour-dependent phrase when pressed:

while true do
  if     i==1 then led.rgb(1.0,0.0,0.0) if pressed then hid.hit("red") end
  elseif i==2 then led.rgb(0.0,1.0,0.0) if pressed then hid.hit("green") end
  elseif i==3 then led.rgb(0.0,0.0,1.0) if pressed then hid.hit("blue") end
  elseif i==4 then led.rgb(1.0,1.0,0.0) if pressed then hid.hit("yellow") end
  elseif i==5 then led.rgb(0.0,1.0,1.0) if pressed then hid.hit("cyan") end
  elseif i==6 then led.rgb(1.0,0.0,1.0) if pressed then hid.hit("purple") end
  elseif i==7 then led.rgb(1.0,0.5,0.5) if pressed then hid.hit("pink") end
  elseif i==8 then led.rgb(1.0,1.0,1.0) if pressed then hid.hit("white") end
  if pressed then
    while sw.get() do end 

... of course instead of writing the colour name, one could start applications, enter passwords (not really save though...), etc.