sheen.bot Logo

2.7 Touch Keys

Touch keys are capacitive touch sensors that detect the presence of a finger. They function like digital buttons without any mechanical movement. The IR remote included with the kit sends unique hexadecimal codes for each button, which can be mapped and used to trigger specific actions in your program.

IR Remote Key Mapping

KeyCodeKeyCodeKeyCode
A0xFFA25DB0xFF629DC0xFFE21D
D0xFF22DD^0xFF02FDE0xFFC23D
<0xFFE01F0xFFA857>0xFF906F
00xFF6897v0xFF9867F0xFFB04F
10xFF30CF20xFF18E730xFF7A85
40xFF10EF50xFF38C760xFF5AA5
70xFF42BD80xFF4AB590xFF52AD

Example Applications

  • Touch-sensitive control panels
  • DIY electronic piano
  • Interactive exhibits

2.7.1 Example Code for the Touch Keys

This example demonstrates how an IR remote can be used to control LEDs and trigger responses such as changing colors, displaying messages, and playing sounds. Each IR button sends a specific signal that is read through an IR receiver connected to pin P15. Depending on the signal received, the system performs a corresponding action.

  • Start by attaching an IR receiver to any of the pins.
  • Attach the external Piranha LED to any of the available pins.
  • Set the chosen pin to LOW initially to prevent the LED from turning on before a button is pressed.
  • Inside the forever loop, the program continuously reads IR values from pin P15.
  • If the A button (value FFA25D) is pressed:
    • All LEDs are turned off.
    • Lamp 0 is set to red.
    • The screen displays Button A.
    • A ringtone ring_1 is played using the TTS Module.
  • If the B button (value FF629D) is pressed:
    • All LEDs are turned off.
    • An external LED on P16 is set to HIGH.
    • The screen displays Button B.
    • The TTS Module speaks "Light on".
  • If the C button (value FFE21D) is pressed:
    • All LEDs are turned off.
    • Lamp 2 is set to green.
    • The screen displays Button C.
    • A different ringtone ring_3 is played.
  • If the D button (value FF22DD) is pressed:
    • All LEDs are turned off.
    • An external LED on P16 is set to LOW.
    • The screen displays Button D.
    • The TTS Module speaks "Light off".
Figure 2.6.2a: IR Remote control logic in Mind+

Figure 2.6.2b: IR Remote control logic in Mind