Introduction: Digital Clock With Mirrored Display Driven by Accelerometers
Hello everybody !!
This project is an original application of a digital clock with mirrored display and driven by Arduino and accelerometers.
With this clock it is possible to place it in front of a mirror and the image of its display will be shown in the correct position, automatically canceling the mirroring effect !!!
This principle is the same as that used in HUD (head-up display) for mirror surfaces or glass, such as on car windshields and aircrafts.
Let's see how it works !!
Step 1: Material
The assembly is very simple using few extra components due to Multi Function Shield for Arduino.
- 01 Arduino Uno R3
- 01 Multi Funtion Shield for Arduino
- 01 MPU-6050 breakout
- 04 Female jumper wires
- Multi Function Shield (MFD):
The use of MFD can simplify and speed up your prototypes development.
There are many features available in this shield:
- 4 digit 7-segment LED display module driven by two serial 74HC595's
- 4 x surface mount LED's in a parallel configuration
- 10K adjustable precision potentiometer
- 3 x independent push buttons
- Piezo buzzer
- DS18B20 temperature sensor interface
- LM35 temperature sensor interface
- Infrared receiver interface
- Serial interface header for convenient connection to serial modules such as Bluetooth, wireless interface, voice module, a voice recognition module, etc.
Note: Before use it I recommend to get more information at Cohesive Computing.
- MPU-6050 breakout:
The MPU-6050 breakout consists in a triple axis accelerometer and gyroscope plus a temperature sensor with following specifications:
- Chip: MPU-6050
- Input Voltage: 3-5V
- ADC: 16 bits
- I/O: standard I2C
- Gyroscope full-scale range: ±250, 500, 1000, 2000°/s
- Accelerometer full-scale range: ±2, ±4, ±8, ±16g
- Temperature sensor range: -40 to +85 ºC
Step 2: Assembly
The assembly is very simple using only a few extra components due to Multi Function Shield for Arduino.
- Insert the Multi Shield into the Arduino.
- Fasten the MPU-6050 breakout on the Arduino board using a tiny screw as shown in the pictures.
There only 04 jumper wires to be connected:
- Red wire: Vcc (+5V)
- Black wire: Gnd
- Green wire: SCL of MPU-6050 breakout to port #6 in the Multi Shield.
- Yellow wire: SDA of MPU-6050 breakout to port #5 in the Multi Shield.
Step 3: SoftWire Library
The SoftWire.h library is an alternative to run with MFD because the original Wire.h library of Arduino can use only the ports A4 (SDA) and A5 (SCL) for I2C communications and these ports are not available in this case.
With SoftWire.h is possible to define new ports for I2C communication protocol that must be in the first lines of the code as shown bellow:
- Instead of to use some specific library to control de MFD, I developed my own code to manage the display with mirrored digit numbers.
- All read data of MPU-6050 are between -16384 and +16384.
- The easiest way to compute the accelerometers data is to convert them in the range of degrees from -90º to +90º using "map" function.
- The same is for the range of temperature from -40ºC to 85ºC, but in this case I have included too a correction factor of +10 as shown below:
AcX = map(AcX, -16384, 16384, -90, 90); AcY = map(AcY, -16384, 16384, -90, 90); AcZ = map(AcZ, -16384, 16384, -90, 90); Temp = map(Temp, -16384, 16384, -40, 85) + 10; // Personal correction factor: +10
Step 4: Configuration
There are 3 buttons to set the clock after activating it:
- Left button: press to adjust the hours. Quickly press to set up step by step. Continuous pressure to advance the hours quickly.
- Center button: set the minutes with the same left button operation pattern.
- Right button: a quick press to move between the time and temperature display.
The potentiometer is used to adjust the brightness of the LED display.
Step 5: Have a Fun
Now it's time to experience something unusual.
Try placing your digital watch or your cell phone showing the time in front of a mirror.
What you see are the mirror images according to the physical laws of optics.
If you repeat the experiment using the Digital Clock of this project, you will see in the mirror the time (or temperature) numbers in the correct way and it does not matter if the clock is upside down, in the left or right position!!
The magic of this is driven by accelerometers that identify the positioning of the clock in three dimensions and provide information to display the numbers compensating for the mirror effect.
Something about Plane Mirrors:
- The image distance equals the object distance.
- The image is unmagnified.
- The image is virtual.
- The image is not inverted.
- Left and right are reversed.
Based on these facts, the code works to interpret two situations:
- The clock is standing: the LED display numbers are reversed from left to right.
- The clock is upside down: the LED display numbers are inverted but not reversed.
With this you can read the LED display in the mirror in any position you put the clock.
We have a be nice policy.
Please be positive and constructive.