33
6. Get the radians and change it into degrees, need to make sure the radians between 0-2*PI and
degrees between 0-360 degrees.
7. Use Output() function to print all the data
Import the library of the compass. The library has many build-in functions to get raw, scaled and
degree values.
HMC5883L Compass Library: #include <HMC5883L.h>
Once you get your heading, you need to add your “Declination Angle”, which is the “Error” of the
magnetic field in your location. You can find yours here: “http://www.magnetic-declination.com/”. Mine
is -2 37’ which is -2.617 degrees and I need -0.0456752665 radians and I will use -0.0457.
Add your “Declination Angle”: float declinationAngle = -0.0457;
Create a function called output() to print all the information of compass, there are four parameters we
need to pass to this function, including raw, scaled, radians and degrees.
Function: Output()
“compass.readRawAxis()” is the function retrieve the raw values from the compass(not scaled).
“compass.readScaledAxis” is the function retrieve the scaled values from the compass(scaled to the
configured scale).
Raw and scaled: MagnetometerRaw raw = compass.readRawAxis();
MagnetometerScaled scaled = compass.readScaledAxis();
Code usage
Lesson 16 – IR control system
Introduction
The Crowtail- IR Receiver module uses the HS0038B which is
miniaturized receivers for infrared remote control systems and it
is the standard IR remote control receiver series, supporting all
major transmission codes. The IR detector has a demodulator
inside that looks for modulated IR at 38 kHz. The Infrared
Receiver can receive signals well within 10 meters. If more than
10 meters, the receiver may not get the signals.This lesson, we
will use the IR Receiver, Infrared Remote Control and two color
LEDs to make a wireless IR control project, which allows us to
turn these two LEDs on or off.
Содержание Crowtail
Страница 48: ......