Arduino Examples
These examples are designed to demonstrate how to use our modules with the Arduino. The Arduino's hardware serial port is not used to connect to our modules, which keeps it available to the USB port. That allows downloading new programs without having to continually disconnect/reconnect things. Most of these examples use the LCD05/LCD03 display module to show the results, but it is also possible to display the results on the PC, as demonstrated in the CMPS03 example. All the modules which use the I2C bus have 1k8 pull-up resistors to 5v. You only need one set of resistors, located near the Arduino, regardless of however many I2C devices you have connected to it.
The Arduino uses 7bit I2C addresses, and our own
documentation uses 8bit addresses. For example our CMPS03 is at
address 0xc0, but on the Arduino you will use 0x60. The Arduino
address is the same as our address, but shifted right by 1 bit.
The binary of 0xC0 is 11000000, the binary of 0x60 is 01100000.
The Arduino will shift this left by 1bit and add the Read/Write
bit automatically. You can find more information about the I2C bus
in our I2C tutorial.
Index: | |
CMPS03 | Magnetic Compass |
CMPS10 | Tilt Compensated Magnetic Compass |
CMPS14/12/11 Serial | Tilt Compensated Magnetic Compass |
CMPS14/12/11 I2C | Tilt Compensated Magnetic Compass |
GP2Y0E02B | I2C Infrared Ranger |
LCD05/LCD03 | I2C/Serial display |
MD03 | 24V 20A Motor Driver |
MD22 | Dual 24V 5A Motor Driver |
MD25 I2C | RD02 Motor Driver |
MD25 Serial | RD02 Motor Driver |
MD49 | 24v EMG49 Motor Driver |
RLY08 | Relay Module |
SD20 | Servo Controller |
SD21 | Servo Controller |
SRF01 | Ultrasonic Ranger |
SRF01 Fake Ranging | Ultrasonic Ranger Fake Range example |
SRF02 | Ultrasonic Ranger |
SRF04/05 | Ultrasonic Ranger |
SRF08 | Ultrasonic Ranger |
SRF10 | Ultrasonic Ranger |
SRF235 | Ultrasonic Ranger |
SRF485WPR | Ultrasonic Ranger |
TPA81 | 8 Pixel Thermal Sensor |
CMPS03 Magnetic Compass
This uses the I2C bus to connect the Arduino to the CMPS03. It
reads the bearing as a two byte integer and displays the bearing
as a number 0-359 on the PC.
Download the arduino_cmps03.ino file |
CMPS10 Tilt Compensated Magnetic Compass
This uses the I2C bus to connect the Arduino to the CMPS10. It
reads the bearing as a two byte integer and displays the bearing
as a number 0-359 on the LCD05/LCD03 display.
Download the arduino_cmps10.ino file |
CMPS14/12/11 Serial Tilt
Compensated Magnetic Compass
This uses a SoftwareSerial port to communicate with the CMPS14/12/11. It
reads the Bearing as an 8 and 16 bit value as well as the pitch
and roll values. All data is printed to the arduino serial monitor
Download the arduino_cmps14_12_serial.ino
file Download the arduino_cmps11_serial.ino file |
CMPS14/12/11 I2C Tilt
Compensated Magnetic Compass
This uses the I2C port to communicate with the CMPS14/12/11. It reads
the Bearing as an 8 and 16 bit value as well as the pitch and roll
values. All data is printed to the arduino serial monitor
Download the arduino_cmps14_12_i2c.ino
file Download the arduino_cmps11_i2c.ino file |
Download the arduino_gp2y0e02b.ino file |
LCD05/LCD03
Simple example of writing text to the LCD05/LCD03 display using I2C
communication.
Download the arduino_LCD05/LCD03.ino file |
MD03 24V 20A
Motor Driver
This example runs the motor forwards and backwards, displaying
the temperature and motor current on the LCD05/LCD03.
Download the arduino_md03.ino file |
MD22 24V
5A Motor Driver
This example runs the motors forwards and backwards. The LCD05/LCD03 is only used to display the software version number.
Download the arduino_md22.ino file |
MD25 RD02
Motor Controller I2C
This example uses the I2C bus to drive the RD02 motors to back and
forth between 2 encoder values. The Encoder count is displayed on
the LCD05/LCD03, as well as the battery voltage.
Download the arduino_md25_i2c.ino file |
MD25
RD02 Motor Controller Serial
This example drives the RD02 motors to back and forth between 2
encoder values. The Encoder count is displayed on the LCD05/LCD03, as
well as the battery voltage.
Download the arduino_md25_serial.ino file |
MD49 24v EMG49
Motor Driver
This example drives the MD49 motors displaying the encoder values,
battery voltage, motor currents and error byte on an LCD05/LCD03.
Download the arduino_md49.ino file |
RLY08 Relay Module
A simple example. Just switches one of the eight relays
on/off.
Download the arduino_rly08.ino file |
SD20 Servo
Controller
Although the Arduino is capable of outputting servo pulses, it
places restrictions on your software and uses up a lot of valuable
I/O pins. By using the SD20 chip, you can control up to 20
servo's.
Download the arduino_sd20.ino file |
SD21 Servo
Controller
The SD21 is a ready wired module which can save a lot of time
compared to the SD20 above. This example moves a servo through its
maximum range.
Download the arduino_sd21.ino file |
SRF01
Ultrasonic Ranger
The SRF01 uses a single pin for both serial input and output. By
using a software serial port, we can make the Arduino do serial
input and output on a single pin as well. You can have up to 16
SRF01's connected to a single pin on the Arduino. The Range is
displayed on an LCD05/LCD03 module.
Download the arduino_srf01.ino file |
SRF01
Ultrasonic Ranger
The SRF01 uses a single pin for both serial input and output. By
using a software serial port, we can make the Arduino do serial
input and output on a single pin as well. You can have up to 16
SRF01's connected to a single pin on the Arduino. This exampe uses
2 SRF01 modules on the same serial port at different addresses.
One module sends an ultrasonic burst while the other listens for it.
Download the arduino_srf01.ino file |
SRF02,
SRF08, SRF10, SRF235 Ultrasonic Rangers
The SRF02, SRF08, SRF10 and SRF235 all use the same I2C
interface. The basic ranging commands are the same, so this
example works for all these rangers.
Download the arduino_srf08.ino file |
SRF04 and SRF05
Ultrasonic Ranger
This example reads the range from the SRF04 and displays it in the
arduino serial monitor. This example will also work for the
SRF05.
Download the arduino_srf04.ino file |
SRF485WPR Ultrasonic Ranger
Using an ST485 for communication this example finds the
address of an SRF485 and reads the range back from it.
Download the arduino_srf485wpr.ino file |
TPA81 Thermal
Sensor
The TPA81 connects to the Arduino using the I2C bus. This example
displays the ambient temperature and 8 temperatures from thermal
sensor, on a LCD05/LCD03 module.
Download the arduino_tpa81.ino file |