Air Bag

From Microduino Wiki
Jump to: navigation, search


Anywhere motion-airbag.jpg

Simulate air bag, when the collision acceleration is larger than a certain value, the LED flashes once representing the air bag is open.

Module List


Module Number Function
mCookie-Core 1 Core board
Battery box 1 Program download and power supply
ColorLED 1 ColorLED
Motion module 1 Detect motion, equivalent to a gyroscope.

Other Equipment

  • USB cable*1
  • Lego or other fixation structures
Anywhere motion-airbag-module.jpg

Module Setup


Anywhere motion-airbag-step.jpg
  • Assemble modules and sensors together:
    • Connect the colorLED to pin 6/7 of Hub;
    • Stick the red core, yellow motion module and green extension module to the yellow battery base;
    • Plug one end of USB cable into the battery base, and connect the other end to the computer.


Programming Thought

Because a ColorLED is required, prepare ColorLED at first. Then declare variable A to store the judgement standard of acceleration. We set A to a negative number, when the acceleration is less than A, that can be consumed as a crash is happened. ColorLED flashes once representing the air bag is open.


Required Program Blocks

Start to Program

1. Initialize the functions.
We need a ColorLED, so prepare the ColorLED at first, the number is 1 and the control pin is 6. Declare A as an int number, for storing the accelerated speed.


Q: Why do we need to set the accelerated speed to -16384?
A: The measurement range of the sensor is two times of gravitational acceleration on the positive and negative direction, and the output range is -32768~32768. In simple terms, the meaning of 16384 is when the measured acceleration is 1 time of the gravitational acceleration, the output of acceleration is 16384.
Q: Well, why is it negative?
A: The acceleration has a direction, the arrow points to positive direction on the motion module, and the positive direction is negative, when the motion module moves along the direction of the X arrow, and crash onto the wall, it will get a negative acceleration from the wall to make it stop.


2. Get acceleration and make a response
Collect Acc/Gyro is for getting the acceleration. Judge the value of the acceleration, if it is less than A, noting that A is a negative number, representing the acceleration of the motion module on the positive direction of the arrow is larger than the set value, the white LED will flash once, representing the air bag is open.


Test the result
Before starting up, confirm the motion module is level. After starting up, crash the motion module to an obstacle along the direction of the X arrow, when the acceleration is larger than 1g, the ColorLED will flash once representing the air bag is open.

Anywhere motion-airbag.jpg

Q: How to set the trigger value of the air bag?
A: When initializing, test the accelerated speed of x axis repeatedly, at this time, crash it, then the largest speed detected during the crash will be assigned to A, so that the trigger value is set.

The initial value of A is 0. The internal program will be executed before the Joystick is pressed.
Read the accelerated speed of X axis. If the accelerated speed is less than A, store it in A. (Crash the device to an obstacle slightly, the system will record the largest collision force automatically.)

Press the Joystick to exit the loop of ColorLED flashing. The green LED flash once (representing the completion of setting).


Detect the collision and then open the air bag.


Technical Specification

Relative Cases