Arduino Accelerometer Tutorial: control a ship bridge using a servo motor

Arduino Accelerometer Tutorial

Arduino Accelerometer Tutorial

Accelerometer sensors are now in most of our smartphones. Accelerometers give smartphones a wide variety of usage and capabilities that we use daily. But, without even knowing that the one responsible for it is the accelerometer!

One of these capabilities is the controllability that the accelerometer give to us. It enables you to control your car in racing games. You also may use a certain app to turn your phone into a remote control for your robot or RC car that uses the accelerometer as the control tool.

So, in this Arduino Accelerometer Tutorial, we are going to use this last feature to make use of the embedded accelerometer sensor on our smartphones. We will use it to control the opening and closing of a ship bridge.

Of course, the bridge is just a servo motor that goes on 0 degrees to close and 90 degrees to open.

Let’s talk about the idea behind this Arduino Accelerometer Tutorial …

Idea:

We are going to use 1Sheeld board with its companion Android/iOS app. Also, we will use the accelerometer shield so we can send any change in any x-axis or y-axis or z-axis to the Arduino. And hence, we can decide whether to change the servo degree to 0 or 90.

 

Getting started:

If this is your first time to deal with 1Sheeld or you want to learn more about it, I recommend checking this quick and easy getting started tutorial.

 

And if you haven’t tried servo motor before, I recommend checking this quick video.

Now, after you’ve become a little bit familiar with 1Sheeld, let’s start!

 

Step 1: Hardware components for the Arduino Accelerometer Tutorial:

–       Arduino Uno.

–       1Sheeld+ board.

–       S90 servo motor.

–       LED.

–       3 * Male to male wires.

–       Arduino USB cable or 9-12v battery.

–       Android/iOS phone with 1Sheeld App installed on it.

 

Step 2: Software components:

 

Step 3: Connection and Schematic:

  • Plug the 1Sheeld board into your Arduino as this:

  • Connect the servo motor and the LED as illustrated below:

  • As I’m using an Arduino UNO board I have switched the 1Sheeld power button to operate on 5v (Not the 3.3v):

  • 1Sheeld have 2 modes: Uploading mode and Operating mode. You can switch between them using the switch close to the Digital pins and is called “UART SWITCH” on 1Sheeld and “SERIAL SWITCH” on 1Sheeld+.

Firstly, you slide the switch towards the “SWITCH” notation which turns the 1Sheeld board into the Uploading mode to let you upload the Arduino code.

Secondly, after you finish uploading the code, slide the switch towards the “UART” notation (or “SERIAL” at 1Sheeld+ board) which turns the 1Sheeld board into the Operating mode to communicate with your smartphone 1Sheeld App.

  • Finally, connect the Arduino via your PC using Arduino USB cable.

 

Code:

I would recommend checking the Arduino Accelerometer Shield documentation to know more about the Arduino Accelerometer Shield functionalities and how to use them.

Now, switch the 1Sheeld board to the Uploading mode, upload this code

Then, Switch the 1Sheeld board to the Operating mode then open the 1Sheeld app and connect it to the 1Sheeld board via Bluetooth.

 

Step 5: Run it:

I have used a piece of cardboard taped to the servo motor as an indication of the bridge movement.

Then you tend the phone towards you and you will see the bridge has opened. It opens with 90 degrees of the servo. Also, the LED is on with a speech comes out from the phone’s speaker. It will tell you that the bridge is now opened and a ship is crossing over.

And once you tend the phone on the opposite side, you will see the bridge closed with 0 degrees of the servo. Also, the LED will be off and a speech comes out from the phone’s speaker telling you the bridge is now closed and a ship has crossed over!

That was it guys ^_^

I hope you enjoyed this quick Arduino Accelerometer Tutorial. And for any questions or opinions about it please don’t hesitate to leave your comment down below.




Related Blogs

Arduino Robotics

Arduino Robotics Series, from a car to a robot arm

Arduino keeps standing out from the crowd of all-around development boards due too its ease of use and budget price. As a result, this has enabled almost anyone to get his own idea into life no matter how crazy or even useless to the whole world it was, except for its maker! Also, it has …

Arduino Robot Arm

How to build an Arduino Robot Arm placed on RC Car

Arduino robots are always funny and definitely more enjoyable when combined with robotic arm! And today, I will walk you through the making of a simple Arduino Robot Arm that’s made of cardboard and how you can attach it over your Arduino Bluetooth RC Car / Robot that you have made so far through this series. …

Arduino Line Following Robot

How to build an Arduino Line Following Robot using Cardboard

Arduino Line Following Robot is one of the easiest and most well-known projects that anyone can make to learn the basics of programming, electronics, and mechanics all in one project. It’s known that this project is common for most of the makers and tech students and today I am going to give it a revisit …

Arduino Obstacle Avoiding Robot

How to build an Arduino Obstacle Avoiding Robot using Cardboard

Back again with another Arduino Bluetooth RC Car tutorial but with an advanced feature that makes your car autonomous by adding ultrasonic sensors to the RC Car you have made before!. Yeah, I know that you may have seen other tutorials using ultrasonic to make the car/robot avoid obstacles ahead, but I am going to …

Arduino Bluetooth RC car

How to make an Arduino Bluetooth RC Car using Cardboard

  Cardboard crafts are one of the most popular and easy to make DIY stuff. Mixing this with the unmatchable enjoyment of RC Cars and the ease of using Arduino, I am going to show you how to make a Cardboard Arduino Bluetooth RC car that you can control via Bluetooth from your smartphone.  …

Arduino Security Camera

Arduino Security Camera System (Arduino Home Hacks #4)

Arduino Security Camera Have you ever wanted to check your home in real time? Afraid that maybe someone has stormed in, don’t remember if you shut the door or not or maybe wanna check if your Hyper-energetic dog has broken any of your dishes AGAIN!! 🙂 Then this is the perfect place for you cause today …