Fredrik Stridsman
Published © MIT

Hidden Maze Mapper

Ever got stuck on that super difficult hidden maze puzzle? Fear no more and build yourself an automatic mapping device!

IntermediateShowcase (no instructions)10 hours2,636
Hidden Maze Mapper

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Seeed Studio Grove - 12-bit Magnetic Rotary Position Sensor / Encoder (AS5600)
×2

Story

Read more

Custom parts and enclosures

Magnet holder OpenSCAD

Magnet Holder STL

Schematics

Schematics

Code

The Arduino code

Arduino
Compile and run on Arduino
#include <SlowSoftI2CMaster.h>

SlowSoftI2CMaster si1 = SlowSoftI2CMaster(A4, A5, true);
SlowSoftI2CMaster si2 = SlowSoftI2CMaster(A2, A3, true);
 
#define I2C_7BITADDR 0x36 //AS5600

#define RAW_ANG_HI 0x0c
#define RAW_ANG_LO 0x0d
  
void setup(void) {
  Serial.begin(115200);
  
  if (!si1.i2c_init()) Serial.println("I2C init 1 failed");
  if (!si2.i2c_init()) Serial.println("I2C init 2 failed");
}

int readAngle(SlowSoftI2CMaster si) {
  if (!si.i2c_start((I2C_7BITADDR<<1)|I2C_WRITE)) {
      Serial.println("I2C device busy");
      delay(500);    
      return -1;
  }
  
  si.i2c_write(RAW_ANG_HI);
  si.i2c_rep_start((I2C_7BITADDR<<1)|I2C_READ);
  byte val_hi = si.i2c_read(true);

  si.i2c_write(RAW_ANG_LO);
  si.i2c_rep_start((I2C_7BITADDR<<1)|I2C_READ);
  byte val_lo = si.i2c_read(true);

  si.i2c_stop();

  return val_hi<<8 | val_lo;  
}

void loop(void){
  
  long val1 = readAngle(si1);
  long val2 = readAngle(si2);

  Serial.print("Sensor1=");
  Serial.print(val1);
  Serial.print("  Sensor2=");
  Serial.println(val2);
    
  delay(10);
}

Credits

Fredrik Stridsman

Fredrik Stridsman

3 projects • 85 followers
A good day is a day when you built or repaired something.

Comments