Reader small image

You're reading from  Hands-On Internet of Things with MQTT

Product typeBook
Published inOct 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789341782
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Tim Pulver
Tim Pulver
author image
Tim Pulver

Tim Pulver is a Berlin-based freelance interaction designer and developer. In his work, he combines his physical prototyping experience and knowledge of interface design with modern technologies such as 3D printing, laser cutting, web technologies, and machine learning to create unique interactive experiences. In recent years, he has worked on interactive data visualizations, web-based audiovisual experiences, musical interfaces, and cables an innovative browser-based visual programming language that enables the creation of interactive audiovisual prototypes without writing any code. He holds a Bachelor of Arts degree in interface design from the University of Applied Sciences in Potsdam, Germany.
Read more about Tim Pulver

Right arrow

Detecting orientation changes

The easiest approach to detect orientation changes of our cube would be to place the following code at the end of our loop function:

if (previousSide != currentSide) {
Serial.print("Side: "); Serial.println(currentSide);
previousSide = currentSide;
}

But the easiest approach is not always the best one. The problem with this approach is that when we switch sides, another side might be detected in between. For example, let's say the cube was lying on the bottom side and you wanted to place it on its top side. While rotating it, it would (for a very short time) detect that it is placed on the side in between, even though we are just rotating it by hand and it does not rest on this side.

To overcome this problem, we should only detect a side change when the last x values were all recorded on the same side. To get this right, we...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Hands-On Internet of Things with MQTT
Published in: Oct 2019Publisher: PacktISBN-13: 9781789341782

Author (1)

author image
Tim Pulver

Tim Pulver is a Berlin-based freelance interaction designer and developer. In his work, he combines his physical prototyping experience and knowledge of interface design with modern technologies such as 3D printing, laser cutting, web technologies, and machine learning to create unique interactive experiences. In recent years, he has worked on interactive data visualizations, web-based audiovisual experiences, musical interfaces, and cables an innovative browser-based visual programming language that enables the creation of interactive audiovisual prototypes without writing any code. He holds a Bachelor of Arts degree in interface design from the University of Applied Sciences in Potsdam, Germany.
Read more about Tim Pulver