Arduino script for MPU-6050 auto-calibration

I while back I did some work on a self-balancing robot using and Arduino Uno and the InvenSense MPU-6050 6DOF sensor. Using the sensor is easy, thanks to Jeff Rowberg’s I2Cdev library and sample code. If you look around line 200 of the MPU6050_DMP6 example arduino sketch that comes with the library you will see the following: // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(220); mpu.setYGyroOffset(76); mpu.setZGyroOffset(-85); mpu.setZAccelOffset(1788); // 1688 factory default for my test chip I did some further reading on the I2CDev forum and found several threads on calibrating the MPU-6050 sensor and determining the optimal offsets. These, apparently, are specific to your device, as well to the exact orientation of the module, once it is installed. I found a significant improvement using the script by Luis Rodenas attached to this forum thread. Below is the Arduino sketch version 1.1 (the most current at the time of this post). For best results, mount your module and run the script, while you have it stable in the position you will use it. For example, on a self balancing robot, have the robot upright in the optimal balanced position and keep it steady while the script completes and you see output with the suggested offsets. You then need to copy these offsets and overwrite the defaults in the sample code (around line 200, as mentioned above). ...

September 27, 2015 · 8 min · 1571 words · Stan

Experimenting with Sound Localization and Arduino

Today I’m going to walk you through my experience trying to localize the source of a sound using Arduino. My goal with this was to add a feature to my robot that would make it more interactive and look more “alive”. Beta 1 What you normally see people doing, as an easy approach, is to measure the volume level from two microphones in which the amplified output is connected to the Arduino analog inputs. Whichever input is higher determines the source direction of the sound. ...

April 4, 2015 · 13 min · 2661 words · Wagner

Bipolar stepper motor control with Arduino and an H-Bridge

It is a well known fact that Stepper motors are awesome! The only downside is that they can be a bit trickier to get going than servos and plain old DC motors. If you are interested in the inner mechanics and theory of stepper motors, check this excellent post on PCB heaven. If you happen to have one of the cheap little 28BYJ-48 steppers with 5 wires and a little driver board with them, check this tutorial instead. Here, I will focus on how to get a bipolar stepper motor (typically 4 wires) working with Arduino and a H-Bridge IC like the L293D , or the drop in improved replacement – SN754410NE . ...

December 2, 2014 · 9 min · 1799 words · Stan

Arduino Joystick Module Example

In one of my rather frequent eBay visits, I came across a nifty little joystick module, much similar to the analog thumb-stick on the PlayStation 2 controllers. The module is very easy to use with an Arduino uno and only costs a few dollars. Several different versions are available from eBay, Adafruit, Sparkfun and other vendors, but they essentially work the same. Overview The module has 5 pins: Vcc, Ground, X, Y, Key. Note that the labels on yours may be slightly different, depending on where you got the module from. The thumbstick is analog and should provide more accurate readings than simple ‘directional’ joysticks tat use some forms of buttons, or mechanical switches. Additionally, you can press the joystick down (rather hard on mine) to activate a ‘press to select’ push-button. ...

October 7, 2014 · 5 min · 1005 words · Stan

Free Arduino reference guide

Erik Verberne teaches Information and Communication Technology (ICT) in Netherlands and looked into the Arduino platform in an attempt to enhance his department’s curriculum. He diligently documented his research and is now sharing it with the community. The result is an e-book of over 200 pages full of examples and tutorials, from Arduino and ATTiny programming tips, to working with LCD and LED displays, playing sounds, detecting obstacles, wireless communication via IR and Bluetooth and much more. See the official thread in the Arduino forum for the latest update and a copy of the Arduino guide and make sure you post a comment there if you find it useful! ...

May 24, 2014 · 1 min · 158 words · Stan

Arduino robot controlled from an Android phone via Bluetooth

Project overview This is a differential steering robot that can be controlled from an Android phone via Bluetooth. The robot’s “brain” is Arduino Uno compatible board (an “Arduino on a breadboard”). The robot uses a JY-MCU Bluetooth module for communication with the Android phone. A custom Android app, created with the MIT App Inventor 2 essentially acts as a remote control, sending commands to the Arduino that tell the robot to move forward, reverse, stop or rotate. ...

January 26, 2014 · 9 min · 1706 words · Stan

Connecting Arduino Uno and the JY-MCU Bluetooth module using SoftwareSerial

My previous post covers the basics of setting up a Bluetooth connection between an Arduino Uno and an Android phone using the JY-MCU Bluetooth module. We connected the JY-MCU Bluetooth module to the Arduino via a serial connection on (digital) pins 0 (rx) and 1 (tx). This uses Arduino’s built in hardware support for serial communication (via something called UART) and requires no additional libraries. The Arduino has a 64 byte serial buffer and can receive and store data in it, while executing other tasks in your program. For some great examples of using serial communication, as well as wealth of other Arduino related info see Nick Gammon’s web-site. There are a couple of downsides of this set-up for Bluetooth connectivity: ...

December 31, 2013 · 6 min · 1219 words · Stan

Arduino controlled LCD using a shift register and the SPI library

Now that I got my recycled 40×2 character LCD working with Arduino, the next step is to get it to show something useful. I decided to add it to my Bluetooth Controlled robot and display data from its two ultrasonic distance sensors (initially). Gradually more interesting info like battery voltage and wheel encoder data can also be shown, as I get those components working. The problem is that now I need to find another 6 digital pins to control the LCD itself. Fortunately, there is an alternative: add a 74HC595 shift register and take advantage of the Arduino SPI library. Here is how: ...

December 20, 2013 · 12 min · 2479 words · Stan

Arduino – Project 3 – “The gripper”

An Arduino Uno controlling a small robotic arm that sorts balls in their respective containers based on the ball colour. A TCRT5000 IR sensor is used for basic colour detection. I’ve made some progress over the weekend. Check it out…

September 3, 2013 · 1 min · 40 words · Wagner

ATTiny85 Mini Robot vs. Black Box

A few days ago we got several ATTiny85 ICs (datasheet) and this is a first video of the small chip in action. Working out the kinks of programming this little guy with an Arduino Uno and getting Arduino libraries to work with it takes a bit of effort and digging around the forums. Still, as a small, light and cheap (can be found for $1.15 online) alternative of an Arduino Uno – it looks very promising! Here is a detailed tutorial on how to program the ATTiny using an Arduino Uno. ...

May 30, 2013 · 2 min · 235 words · Stan