Interfacing Ultrasonic Sensor HY-SRF05with PIC Microcontroller is the fourth tutorial in a series of tutorials on Design Embedded System with PIC Microcontroller. In this tutorial we will measure the distance of an object using ultrasonic sensor and transmit it using Bluetooth.
In case you are new to PIC Microcontroller and MPLAB X IDE I strongly suggest to visit the tutorial – Getting started with MPLAB X IDE.
For interfacing Bluetooth with PIC Microcontroller we will require the following components which can be purchased in OpzLab web store. Links to the individual components are also provided.
Interfacing Bluetooth with PIC Microcontroller is the third tutorial in a series of tutorials on Design Embedded System with PIC Microcontroller. In this tutorial we will control two DC Motors and a buzzer connected to the PIC microcontroller from our android phone via bluetooth.
In case you are new to PIC Microcontroller and MPLAB X IDE I strongly suggest to visit the tutorial – Getting started with MPLAB X IDE.
For interfacing Bluetooth with PIC Microcontroller we will require the following components which can be purchased in OpzLab web store. Links to the individual components are also provided.
Follow the below tutorial to control the DC Motors in forward, reverse, left and right direction and blow the buzzer horn using your android phone using Bluetooth.
After the project is created open MPLAB Code Configurator and proceed with the below settings.
Do Not disable Low Voltage Mode and Do Not change MCLR settings. Let it be default.
Change the HF Internal Clock to 8 MHz and Clock Divider to 1 under Project Resource -> System -> System Module -> Easy Setup.
Assign the Output Ports for the motor controls and buzzer and disable analog for the ports under Project Resources -> System -> Pin Module.
Double Click on Device Resources -> EUSART -> EUSART1 to select UART1 module for bluetooth serial communication.
Enable Receiver and Transmitter under Project Resources -> Peripherals -> EUSART1. Keep all other default settings make sure the Baud Rate is set to 9600.
Change the Rx and Tx ports to pin number 2 and 3 respectively. Make sure to remove Rx1 and Tx1 assignments on any other pins.
Disable Analog on all the port pins.
Save and and click on Generate to create Header and Source Files. Close MPLAB Code Configurator.
Hit the Download button to program and run the device from MPLAB X IDE. The pic microcontroller will be programmed after few seconds.
The red light on the Bluetooth module will blink rapidly. It is in discover mode. Scan for HC-05 device in you android phone and pair it with pass code 1234.
Search for the paired HC-05 device and connect. The red light on the Bluetooth module will now blink less frequently. A serial communication link has been now established between your android phone and the PIC microcontroller.
Send the below commands to interact with the motors and buzzer.
You can also configure buttons in the android app to control the motors and the buzzer. Good Luck!
In case you are new to PIC Microcontroller and MPLAB X IDE I strongly suggest to visit the tutorial – Getting started with MPLAB X IDE. If this is your first interfacing with PIC microcontroller please go through Interfacing LED with PIC Microcontroller tutorial for a complete overview of the programming and execution process.
For interfacing DC Motor with PIC Microcontroller we will require the following components which can be purchased in OpzLab web store. Links to the individual components are also provided.
Hit the Download button to program and run the device from MPLAB X IDE. The pic microcontroller will be programmed after few seconds, the program will run the dc motors in forward, reverse, left and right directions per 10 seconds each.
In case you are new to PIC Microcontroller and MPLAB X IDE I strongly suggest to visit the tutorial – Getting started with MPLAB X IDE.
For interfacing LED with PIC Microcontroller we will require the following components which can be purchased in OpzLab web store. Links to the individual components are also provided.
Download and install MPLAB X IDE latest version from Microchip site. User Guide (online).
Download and install MPLAB XC8 compiler latest version from Microchip site. You will get the download links under download tab in the page.
Start MAPLAB X IDE and navigate to plugins. Search for MPLAB Code Configurator and install the plugin. For help, visit Microchip video tutorial.
Connect PICKIT3 Programmer/Debugger to PC / Laptop usb port and restart MPLAB X IDE. PICKit3 documentation can be downloaded from Microchip site. Poster link.
You are ready for your first project. Happy Learning!!