Peter Ma
Published © Apache-2.0

3D Magnetic Block Breaker

Combining Infineon 3D Magnetic Sensor and classic Block Breaker from Unity tutorial.

BeginnerFull instructions provided4 hours886

Things used in this project

Hardware components

3D Magnetic Sensor 2Go
Infineon 3D Magnetic Sensor 2Go
×1

Software apps and online services

Unity
Unity
Arduino IDE
Arduino IDE

Story

Read more

Schematics

3dGo

Schematic

Code

Arduino Code

Arduino
Arduino Code used for Brick Breaker
#include <Tle493d_w2b6.h>

Tle493d_w2b6 Tle493dMagnetic3DSensor = Tle493d_w2b6();

//for firing
float norm = 0;
bool start = false;
int frame = 0;

void setup() {
  Serial.begin(9600);
  while (!Serial);
  pinMode(14, OUTPUT);

  Tle493dMagnetic3DSensor.begin();
  Tle493dMagnetic3DSensor.begin();
  Tle493dMagnetic3DSensor.setWakeUpThreshold(1,-1,1,-1,1,-1);
  Tle493dMagnetic3DSensor.disableTemp();
  norm = Tle493dMagnetic3DSensor.getNorm();
}


void loop() {
  Tle493dMagnetic3DSensor.updateData();
  
  Serial.print(Tle493dMagnetic3DSensor.getNorm());
  Serial.print(" ; ");
  Serial.println(Tle493dMagnetic3DSensor.getAzimuth());

  //It doubles when press down, and halves when releases
  if((abs(Tle493dMagnetic3DSensor.getNorm()) > abs(norm*1.5))){
    start = true;
  }
  else if
  ((abs(Tle493dMagnetic3DSensor.getNorm()) < abs(norm/1.5)))
  {
    start = false;
  }
  
  norm = Tle493dMagnetic3DSensor.getNorm();
  if(start)
  {
    digitalWrite(14, HIGH);
  }
  else
  {
    digitalWrite(14, LOW);
  }
  delay(10);
}

Full Game repo

Full Brick Breaker demo along with Unity Tutorial

Credits

Peter Ma

Peter Ma

49 projects • 359 followers
Prototype Hacker, Hackathon Goer, World Traveler, Ecological balancer, integrationist, technologist, futurist.
Thanks to Udemy.

Comments