Talking To Tiles

A project log for A Tile Based MacroPad

Using "magic" tiles to assign keystrokes to this MacroPad's keys.

michael-gardiMichael Gardi 09/27/2023 at 01:410 Comments

With tile construction set, we now have to calibrate the reading of tiles and establish a "protocol" for mapping tiles to macros.

I'm using the same SS49E Linear Hall Effect Sensor that I did with the TMD-3 project so I know that the Analog To Digital (ADC) default reading from the sensor (with no magnetic field nearby) is the middle of the range. Furthermore a magnet with one polarity will move the reading to higher values while the opposite polarity moves it to a lower values.  So I printed a tile slot and populated it with a single SS49E sensor. The sensor is pressed into a precisely sized and positioned indentation at the bottom of the slot with the leads extending below.

I wired the sensor to my pro Micro.

Pro MicroSS49E

I wrote a simple sketch to read the sensor.

  MacroPad Sensor Calibration.

int sensorPin = A0;   // Sensor input pin.
int sensorValue = 0;  // Sensor value.
int sensorMid = 0;

void setup() {
  Serial.println("MacroPad Sensor Test!");
  sensorMid = analogRead(sensorPin);

void loop() {
  // Read the value from the sensor.
  sensorValue = analogRead(sensorPin) - sensorMid;
  if (abs(sensorValue) > 20) {
      // Magnet detected.

Using this code I established the following table.

Assigned Number01234567
Magnet Distance0 mm1 mm2 mm3 mm0 mm1 mm2 mm3 mm
Sensor Reading1801047953-164-114-81-49

The important thing here is the first and last rows. If the value read from the sensor is "close" (there will always be a little variance between different sensors and tiles) to one of the values in the last row, then that position will be assigned to the number in the first row from the same column. So for instance if the sensor value read is say 50, then the value for that position will be assigned a value of 3

Remember that each slot has two sensors. When you drop in a tile, the assigned value from the left position will be combined with the assigned value from the right position to form a two digit "key" that will map to a specific macro. Astute readers will realize that each tile will thus have a valid two digit octal number key associated with it. Of course care must be taken to make sure that all tiles have a unique key.

So here are my first 12 tiles ready to have the top labels attached.

12 down 52 to go.