PIC24F Examples
These examples are designed to demonstrate how to use the PIC24F family, in this case a PIC24FJ16GA002 to communicate with our modules. Most of these examples use the LCD03 display module to show the results. All the modules which use the I2C bus have 1k8 pull-up resistors to 5v. You only need one set of resistors for the whole I2C bus regardless of however many I2C devices you have connected to it. You can find more information about the I2C bus in our I2C tutorial.
| Index: | |
| CMPS03 | Magnetic Compass |
| SRF01 | Ultrasonic Ranger |
| SRF04/05 | Ultrasonic Ranger |
| SRF05 | Ultrasonic Ranger |
| SRF08 | Ultrasonic Ranger |
| SRF02 | Ultrasonic Ranger |
| SRF10 | Ultrasonic Ranger |
| SRF235 | Ultrasonic Ranger |
| TPA81 | 8 Pixel Thermal Sensor |
| SD20 | Servo Controller |
| SD21 | Servo Controller |
| MD03 | 24V 20A Motor Driver |
| MD22 | Dual 24V 5A Motor Driver |
| MD25 | RD01 Motor Driver |
| RLY08 | Relay Module |
CMPS03 Magnetic Compass
This uses the I2C bus to connect the PIC24FJ16GA002 to the CMPS03. It reads the
bearing as a 16 bit integer and also reads the bearing as a byte.
These are then displayed to the LCD03.

| Download the CMPS03_pic24f.zip file |
SRF01 Ultrasonic Ranger
The SRF01 uses a single wire for both serial input and output. We have connected
this to 2 pins of the PIC24FJ16GA002 for input and output. A diode is put in
place to stop the SRF01 from driving the output pin when sending data back.
Range is displayed on an LCD03 module.

| Download the SRF01_pic24f.zip file |
SRF04 Ultrasonic Ranger
As the SRF04 and SRF05 use the same method of communicating this example is compatible
with both the SRF04 and SRF05.

| Download the SRF0405_pic24f.zip file |
SRF05 Ultrasonic Ranger
This example uses the SRF05 in one pin mode, where the Trigger and Echo signals
appear on the same pin. Note the SRF05's mode pin is connected to ground to
place it in one pin mode.

|
Download the SRF05_pic24f.zip file |
SRF08 Ultrasonic Ranger
The SRF08, SRF02, SRF10 and SRF235 all use the same I2C interface and the basic
ranging commands are the same. This example works for all these
rangers. The light reading is only available on the SRF08.

|
Download the SRF08_pic24f.zip file |
TPA81 Thermal Sensor
The TPA81 connects to the PIC24FJ16GA002 using the I2C bus. This example displays the
ambient temperature and 8 temperatures from the thermal sensor on an LCD03 module
and also drives a servo.

| Download the TPA81_pic24f.zip file |
SD20 Servo Controller
This example shows how to drive servos by using
the SD20 chip.

| Download the SD20_pic24f.zip 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 all servos through their maximum range.

| Download the SD21_pic24f.zip file |
MD03 24V 20A Motor Driver
This example runs the motor at varying speeds, displaying the
temperature, motor current and speed on the LCD03.
| Download the MD03_pic24f.zip file |
MD22 24V 5A Motor
Driver
This example drives both motors and used the turn register to alter their
speeds. It displays the speed and turn register values to the LCD03.

| Download the MD22_pic24f.zip file |
MD25 RD02 Motor
Controller
This example drives the RD02 motors and displays the encoder values on the LCD03
in hex format, as well as the battery voltage and current for each motor. It runs the motors back and forth between 2 values output by the
encoders.

| Download the MD25_pic24f.zip file |
RLY08 Relay Module
Example of switching relays on and off by passing values to the relay states
register.

| Download the RLY08_pic24f.zip file |