Arduino Tutorial 36: Understanding How to Use Tilt Switches in Your Projects

Tilt Sensor
This Circuit Gives Visual Indicator if Board Has Been Tilted

This is a simple project that allows you to create a circuit which will give a visual indication if the breadboard has been tilted. In the upright position, the Green LED is illuminated. To the left of the board is a tilt switch. If the project is tilted, the switch will go from the closed to the open condition. This can be detected on the arduino, and then the red LED is illuminated. The video below explains how to do this simple project.

You can get the kit we are using in these lessons HERE. You should create your own code based on the instructions in the video, but if you are having trouble, I include the code developed in the video below:

 

Arduino Tutorial 35: Understanding How to Use a Stepper Motor

In this lesson we give you several examples of how to connect and program a stepper motor. Stepper motors are useful because they can produce very large torque at low RPM and are capable of extremely precise positioning. They are somewhat tricky to use, and you must be careful to not try and power them from an Arduino. Arduino can control stepper motors, but they must be powered from an external power supply.

If you want to follow along at home, you can order the Arduino Kit we are using HERE.

This is the code that allows you to toggle the direction of the stepper motor by pressing a pushbutton. The video shows all the details and how to connect the motor up.

 

9-Axis IMU LESSON 12: Passing Data From Arduino to Python

In this lesson we show how to pass data from Arduino to Python using a Com Port. This is important for our 9-Axis IMU project as we want to take advantage of the processing power and 3D graphics capabilities of Python. Our goal is to get the date from Arduino to Python, and then create a dynamic 3D visualization of our system. The first step in this goal is to pass the data from arduino to Python.

In order to do this, a first step is to install the pyserial library. If you followed our python installation tutorial in lesson 11, then it is easy to install pyserial by just opening a windows command prompt, and then typing:

pip install pyserial

If this does not work, likely you did not install python according to the instruction in lesson 11.

In order to show a simple demonstration of passing data, we can use the following code on the arduino side, which just generates x, y, and z numbers and passes them to Python.

We can grab these numbers from the Com port on the Python side with the following code. Note that you should use the com port your arduino is on, which likely will not be the same as mine (which was ‘com5’).

The above example is just a simple method for passing different channels from Arduino to Python.

 

For our IMU project, we want to use the code we left off with Lesson 10. However, note we can scale back on the number of data channels, because we just want the calibration data and then the final roll, pitch and yaw numbers. This is the arduino code that will pass those parameters.

Then, on the Python side we can grab and parse the data with this code.

In the next lesson we will install Vpython and begin building our code to create dynamic 3D visualizations of our system.

Making The World a Better Place One High Tech Project at a Time. Enjoy!