In the first part, we covered the basics on how to use the accelerometer. Today, we will take the horizontal camera device we created in part 1, and create a handheld version. When dealing only with sensors, all we need is an Arduino, a breadboard, a sensor, and some electronic parts to test it. But to create a practical device, we need to think about the materials for the non-electrical circuit parts, the external appearance, and some other factors. Today, we will go over them by creating a handheld version.
Expected time to complete: 90 minutes
Parts needed:
First, let’s think about the design of the device and prepare the materials accordingly. We can use the electrical circuit from the last session for starters. Now, let’s think about how to use various materials and parts to create a handheld version.
Picture 1 Horizontal camera platform from part 1
When we look back at the horizontal camera platform that we created in part 1, we notice that we can probably use the extended part to create a handheld version. Try to get a brief image of the completed item in your head. Here is a rough sketch I did (Figure 1).
Figure 1 Design plan for the handheld horizontal camera device
Let’s start creating the device with this image in mind. We can decide the details first, but unless you know how to connect a servo motor with the case or know which materials/parts to choose considering strength and workability, it’s probably better if you go to a hardware store and decide the details based on the items you find there.
I couldn’t think of a specific part to fix the servo motor at this point. I went to the hardware store to find one. Ideally, I’d like to create a nice 3D model first, then create an original device. The problem is that the camera platform created by the 3D printer seemed weak, so I gave that up. There are other ways like using a CNC milling cutter to cut out iModela-like materials from a 3D design. If you want to create custom parts, it can get tricky. So for now, we will use handy parts we can find at the hardware store.
Picture 2 Materials I bought from the hardware store
I went to the hardware store and picked out some parts that looked useful for the device. I think connecting the servomotor will be the key in this project. Hence, I took the servomotor to the store and tried it with different parts to find the most suitable ones.
Let’s start building. I used wood for the handle part because it’s easy to work with. By using a jigsaw, it’s easy to cut out complicated shapes. I will use steel parts for the part that connects the servomotor because it is robust.
Picture 3 Steel parts that looks useful for connecting the servomotor
Picture 4 The Servomotor which will be set on the handle
Picture 5 Using a jigsaw to make room for the servomotor in the handle
Picture 6 Placing the servo motor in the handle
Picture 7 Connecting the servo motor and the steel parts with screws using the holes (backside)
Picture 8 Connecting the servomotor and the steel parts with screws using the holes (front side)
Except for the middle hole, the holes on the white plastic connector part on the servo motor are small. But it will not break even if you twist the screw. So, you can insert the screw directly as shown in Picture 7.
Picture 9 Connecting it with the servomotor
Ok, the first servo motor looks pretty good. Next, let’s think about how to mount the second servo motor.
Picture 10 Fixing steel part with screws and nuts
When I connected the first servomotor, there was another steel part of a different size. Hence, to fix the second servo motor on the platform, I used this part with screws and nuts.
Picture 11 Using screws and nuts to fix it, the second servomotor is now set on the platform
After building this, I checked the connecting parts by hand. There doesn’t seem to be any problem in terms of strength.
Before mounting the other parts after the servomotor, let’s assemble the device and see how it turns out.
Picture 12 Temporary assembling the device
Arduino UNO is too big. Even worse, we probably need 2 breadboards for wiring, which makes it much thicker…
Let’s use the Arduino Pro Mini we used in the RC car article and make it smaller.
Picture 13 Arduino Pro Mini and the accelerometer
By using Arduino Pro Mini, we can fit all parts on one breadboard. Now, let’s build the circuits. First, we will assemble the accelerometer. The circuit is the same as the Arduino UNO from our previous article. With a Pro Mini, the connecting parts are different, so pay attention to the letters on the board when assembling.
Figure 2 Circuit that connects the accelerometer to Arduino
Picture 14 Building the circuit
Everything fits on one breadboard!
Picture 15 Mounting it on the device
The backside of the breadboard has a double-sided tape. So, stick it on the handle part.
Now that we have some basis, let’s adjust the values on the accelerometer. Using the program from part 1, check the sensor value before connecting to the servo motor. Now, in this case when we hold the hand, the accelerometer will be horizontal by default, so consider that when setting up the program.
Figure 3 Checking the values from the accelerometer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
//******************************** //Program to get the values from the accelerometer sensor //******************************** void setup() { //Reinitialize serial monitor Serial.begin(9600) ; } void loop() { long x , y , z ; x = y = z = 0 ; x = analogRead(3) ; // Xaxis y = analogRead(4) ; // Yaxis z = analogRead(5) ; // Zaxis Serial.print("X:") ; Serial.print(x) ; Serial.print(" Y:") ; Serial.print(y) ; Serial.print(" Z:") ; Serial.println(z) ; delay(50) ; } |
Holding the device horizontally, record the default value of XYZ. Then, tilt the device 90 degrees front/back and left/right, then record the minimum/maximum value relative to the XY axis. (The minimum/maximum is at the center of the accelerometer = horizontal value)
Use this value and reflect them to the program to move the servomotor.
Here the values we got:
X axis Min 355 – Max 751 | Center553 (Front/back198)
Y axis Min 316 – Max 758 | Center536 (220)
The servomotor SG90 we are using will rotate 90 degrees, so when parallel, it’s 45 degrees. Then, mount it with the program so that even if it tilts by 45 degrees (0 ~ 90 degrees), it will maintain the parallel status.
Figure 4 Completed circuit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
//******************************** //Second program to get the values from the accelerometer sensor //******************************** #include <Servo.h> Servo myservoX; Servo myservoY; void setup() { //Reinitialize serial monitor Serial.begin(9600) ; myservoX.attach( 5 ); myservoY.attach( 6 ); } void loop() { int i ; long x , y; //Get the average by reading each data 100 times x = y = 0 ; for (i=0 ; i < 100 ; i++) { x = x + analogRead(0) ; // Read X axis y = y + analogRead(1) ; // Read Y axis } x = x / 100 ; y = y / 100 ; int rotateX = (x-198)/7.8888; // Equation to find the angle Serial.print("X:") ; Serial.print(x) ; Serial.print(" ") ; Serial.print(rotateX) ; int rotateY = (y-220)/7.02; myservoY.write( 90-rotateY ); Serial.print(" Y:") ; Serial.print(y) ; // Y axis Serial.print(" ") ; Serial.println(rotateY) ; // Y axis delay(10) ; } |
We are done. Let’s mount the camera and see if it works.
Picture 16 Placing the smartphone on the platform
Let’s hope it works!
Turn On! Wow, it looks like a newborn deer!
When there was nothing on it, it was pretty smooth. But as soon as I placed the smartphone, the servo motor seemed to lack power, even though it was trying really hard. But this is all part of creating something new I guess. Regardless, it looks like the smartphone is too heavy.
To improve on this, we can use stronger servomotors or use a lighter smartphone. If we use a USB webcam or a GoPRO, it may work better. To change the servomotors, we need to get a servomotor that performs accordingly to the weight of the smartphone. When choosing a servo motor, do so by looking at the rotating angle, speed, torque, operating voltage, and size. The SG90 we used today had a torque of 1.8kgf・cm, speed of 0.1 second/60degrees, and an operating voltage of 4.8V (~5V). We didn’t have enough power today. It might be a good idea to get one with a stronger torque. The necessary torque for a servomotor can be calculated with the equation below. However, the actual center of gravity can be quite difficult to find. Try using an approximate number when using the equation.
Necessary torque for a servo motor = Center of gravity x distance x angle
Today, we mounted the horizontal camera device handheld version. In the process, we experienced many issues, including choosing the right material for the device and other technical problems after the device was assembled. This type of horizontal camera device is usually known as steadicam or camera gimbal. Recently, with the rise of quadcopters, there are many camera platforms available.
To take our platform to such levels, we need to use something called a brushless motor, because the noise made by a regular servo motor when it rotates can interfere when taking a video. We may also need a multi-axis sensor with a gyro instead of a 3-axis sensor for the accelerometer sensor to make the motion smoother. The list of improvements goes on and on.
But taking it one step at a time and learning new things about electric circuits and materials on the way is what makes working with electronics awesome.
In our next article, we will deal with “sound” using Arduino!