Xiphoray Zhang
Created September 28, 2017

Hodor

Hodor can be used in a hotel or at home. When somebody opens the doors or windows when you're sleeping, Hodor will warn you.

Work in progress79
Hodor

Things used in this project

Story

Read more

Schematics

Hardwave connetion

Code

GetplaceData

Java
Get data of place at onCreate().
PeripheralManagerService peripheralManagerService = new PeripheralManagerService();
try {
	i2cDevice = peripheralManagerService.openI2cDevice(I2C_ADDRESS, PLACE_SENSOR_SLAVE);
	Place_X = i2cDevice.readRegWord(REGISTER_PLACE_X);
	Place_Y = i2cDevice.readRegWord(REGISTER_PLACE_Y);
	Place_Z = i2cDevice.readRegWord(REGISTER_PLACE_Z);
} catch (IOException e) {
	e.printStackTrace();
}

Checkplace

Java
Check if the Hodor is moved by other
if((abs(Now_X - Place_X) > Threshold_X) || (abs(Now_Y - Place_Y) > Threshold_Y) || (abs(Now_Z - Place_Z) > Threshold_Z)){
  Warning = true;
}

Credits

Xiphoray Zhang

Xiphoray Zhang

0 projects • 1 follower

Comments