Software apps and online services
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 LED display will be shown in the correct position, automatically cancelling 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.
This is the material list you need:
- 01 x Arduino UNO R3
- 01 x Multi Funtion Shield (MFD) for Arduino
- 01 x MPU-6050 breakout
- 04 x 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.
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
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.
There is an additional library you need:
- <SoftWire.h> // Similar to Wire.h library to run with Multi-Function Shield
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 Multi-Function Shield.
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
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 press to advance the hours quickly.
- Center button: set the minutes with the same left button operation pattern.
- Right button: a quick press to move for temperature mode.
Note: At temperature mode is possible to change to Fahrenheit or Celsius mode pressing the Left button.
Note: In Temperature Mode is possible to change the status to Fahrenheit or Celsius pressing the Left button.
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 at mirror the time (or temperature) numbers in correct positioning and does not matter if the the clock is upside down or not!
The magic of this is driven by accelerometers that identify the positioning of the clock in three dimensions and provide correct information to the display.
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.