This time, my mind went into world of crazy thoughts and came up with one of the most craziest project idea I've ever had, or heard of, and it was to control three colors of RGB LED with three axis of gyroscope, so you can make any color you want just by changing direction or orientation of cube, and from there, the name GyroCube came into existence, we can play games with it, like: say the name of color and then try to make it, or the hardest one is that, at one angle all the three colors will turn off, try to find that orientation as fast as possible.
Trust me everyone loves it from kids to elders, because it has never been this easier to mix the colors.
It is an extremely cool desktop gadget/fidget to have, never gets you bored and brings smile to everyone who plays with it, regardless of age.
Lets get started---
Because it is a quite long Instructable, I made a complete video tutorial,I recommend everyone to watch, to at least have an idea how it works.
Ignore my accent please because I was really tired during voice-over.
Step 1: Things Required
First you should know how to use soldering iron, download and install softwares and how to read schematics, don't worry if you do not know, you can learn these things in a matter of hours.
https://www.utsource.net/ is an online platform for technicians, Makers, Enthusiasts, Kids to buy electronic components
7.) 220 ohm resistor, only one of it.
10.) Universal charger this is required for charging the battery, this is a kind of charger where you have and put the battery inside it, see picture for reference.
11.) Sunmica Sheets I used them for making the box look for them in hardware store
12.) Glue to stick the sheets together
12.) Tiny magnets.
Step 2: Connect Gyroscope to Arduino
Gyroscopes work on the principle of Coriolis acceleration. Imagine that there is a fork like structure, that is in constant back and forth motion. It is held in place using piezo electric crystals. Whenever, you try to tilt this arrangement, the crystals experience a force in the direction of inclination. This is caused as a result of the inertia of the moving fork. The crystals thus produce a current in consensus with the piezo electric effect, and this current is amplified. The values are then refined by the host microcontroller.
The MPU 6050 is a 6 DOF (Degrees of Freedom) or a six axis IMU sensor, which means that it gives six values as output. Three values from the accelerometer and three from the gyroscope. The MPU 6050 is a sensor based on MEMS (Micro Electro Mechanical Systems) technology. Both the accelerometer and the gyroscope is embedded inside a single chip. This chip uses I2C (Inter Integrated Circuit) protocol for communication.
The MPU 6050 communicates with the Arduino through the I2C protocol. The MPU 6050 is connected to Arduino as shown in the following diagram. Here, MPU 6050 module has a 5V pin, then you can connect it to your arduino’s 5V pin. Else, you will have to connect it to the 3.3V pin. Next, the GND of the arduino is connected to the GND of the MPU 6050.
SCL----A5 (Analog 5)
SDA---A3 (Analog 4)
INT----D2 (Digital Pin 2)
After completing the connections connect arduino to PC.
Step 3: Arduino IDE
IDE is an Integrated Development Environment used to write and upload programs in arduino, so we need to install this software.
The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. It runs on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing and other open-source software.
Download and install the arduino IDE from this link
I recommend downloading the latest version because I had compilation errors when using the older version, so if you have the same problem try installing latest one.
Step 4: Download Library
A number of libraries come installed with the IDE, but you can also download or create your own.
Download the library from this link extract it and then open it, you will see the folder named arduino inside the main folder, open it and you will see something as shown in image 2, from here you need to copy two folders named I2Cdev and MPU6050 now paste this in the arduino library, to find it follow this--
If you installed the IDE then go to your C drive, Program files x86 and then open the folder named arduino and inside it you will se another folder named Libraries, open it and then paste those two folders which we copied.
Step 5: Gyroscope Calliberation
In this step we will calculate offset values of the sensor, it is simple and important.
Download the calibration Sketch from this link, extract it and you will see a file named MPU6050_Calibration open it.
compile the sketch, and then upload it to arduino.
Open serial monitor and wait till the offset values are being calculated.
Offset values for my sensor are shown in image 2.
Note the X, Y and Z offset values for Gyroscope only, not for accelerometer.
Step 6: Final Upload
Now download the final program for GyroCube from here
Open it and then scroll down to the point shown in the image.
Now here you have to enter your X, Y, and Z offset values for gyroscope.
After entering the values upload it to arduino.
Step 7: Prepare the LED
We need common anode LED for the project, but it was not available in my area, so I chopped off three LEDs form RGB LED strip, and these LEDs had separate Anode and cathode for each colour, and since we want common anode LED so I soldered there positive ends together, and added headers to separate cathodes.
And finally I soldered them on prefboard, connected all the positive ends together, all the negative terminals of blues together, all the negative terminals of greens together and all the negative terminals of reds together, so finally it will act like one single common anode LED
Here is the schematic for common anode LED in Autodesk Circuits
Step 8: Testing Things
Connect the things on breadboard according to the schematic below for first test.
Remember that the Gyroscope is not shown in the schematic so simulation will also not work but it is connected according to Step:2
When you will move the Gyroscope you will see change in colours, to see how watch the video attached in Intro
Step 9: Time to Fix Everthing
Solder everything together on a prefboard,if you want you can even design your own PCB circuit on Autodesk Circuits
Arduino and Gyroscope slides in nicely in female headers.
Power the project with battery and make sure that everything is still working.
Step 10: Making the Box
Nothing is complicated here, just cut the sheets of Sunmica and stick them together with glue, dimensions will depend on your size of battery.
Step 11: Charging Battery
Solder wires on terminals coming out of charger then connect them to battery and plug the charger in switch board, do not worry about polarity, it will be adjusted automatically by the charger.
Step 12: Conclusion
In future I'll connect Bluetooth module inside it and will adjust brightness of my room just by rotating it clockwise or counter-clockwise, stay tuned for that.