35
1. Import the math library and declare the pin of the analog gyro.
2. Declare variables to store the values of the analog gyro.
3. Setup the analog gyro as input and initialize the serial monitor.
4. In the setup() function, read the value from the analog gyro and use it as a reference value.
5. Read the value from analog gyro and convert it to angular velocity and print.
Code overview
Code usage
"Float" is a floating-point data type. The FLOAT data type is used to store single-precision
floating-point numbers or double-precision floating-point numbers. Single-precision values of
floating-point types have 4 bytes. "Double" (double precision floating point) is a data type used by
computers. Rather than a single-precision floating-point number (float), a double (double-precision
floating-point number) uses 64 bits (8 bytes) to store a floating-point number.
Float and double: float reference_Value=0; double angularVelocity;
To obtain the reference value is the reason why we need to calibrate the analog gyro in beginning. We
use for() statement to get the analog gyro data 1000 time in 2 seconds and then get the average of
the value as a reference value. Therefore, within 2 seconds after uploading the program, you should
not move the sensor because the sensor is being calibrated.
Reference value: reference_Value = sum/1000.0;
Arduino Uno/Crowduino Uno x1
Crowtail - LED x1
Required Parts
Crowtail- Bluetooth Low Energy Module HM-13 is an easy
module to use and designed for transparent wireless serial
connection setup. The serial port Bluetooth module is fully
qualified BT Version V4.0 EDR + BLE dual mode with
complete 2.4GHz radio transceiver and baseband.
Bluetooth devices are widely used in our daily life, and they are powerful! Such as Bluetooth function
of your mobile phone, Bluetooth headset, Bluetooth speaker and so on. In this lesson, we will learn
how to use this bluetooth to control the led.
Lesson 17 – Use of Bluetooth
Introduction
Содержание Crowtail Deluxe Kit
Страница 47: ......