Posts

Showing posts from 2015

HC-SR04 Ultrasonic Sensor code for Distance Measurement

Image
The code written below is for the HC-SR04 Ultrasonic Sensor using the PIC16F877A microcontroller. To start measurement, Trig of SR04 must receive a pulse of high (5V) for at least 10us, this will initiate the sensor will transmit out 8 cycle of ultrasonic burst at 40kHz and wait for the reflected ultrasonic burst. When the sensor detected ultrasonic from receiver, it will set the Echo pin to high (5V) and delay for a period (width) which proportion to distance. To obtain the distance, measure the width (Ton) of Echo pin. Time = Width of Echo pulse, in uS (micro second) ● Distance in centimeters = Time / 58 ● Distance in inches = Time / 148 ● Or you can utilize the speed of sound, which is 340m/s Project Schematic PROJECT CODE For the below code, the measured distance will be displayed in binary on an LED array on PORTC of the microcontroller. Eg. 5cm will = 00000101 You should be able to copy paste it. /****************************...

Gesture Controlled Robot Arm Using PIC16F877A

Image
Introduction This project uses a wearable gesture device to operate a robotic arm. The robot arm will be controlled by the wearers natural arm movements. Main Components 1 x PIC16f877A  1 x AM3X 3-axis accelerometer - to detect arm movements 2 x Bend / flex sensors - to detect wrist and finger movement  How it works The voltages from the sensors are fed into the ADC pins of the PIC16F877A micro controller. The ADC module converts the analogue voltages into their equivalent digital values. We then use these values to control the servos on our robot arm. Flex sensor The Flex Sensor works in the same way as a variable resistor. Its resistance varies when flexed. You can purchase flex sensors online, but you can also make your own which is what I did for this project. If you want to know more on how to make a flex sensor, check out   Making a flex sensor. This is used in a voltage divider circuit and the output voltage can be calculate...