Pulsing Hubby Detector using PIC12f683 microcontroller

Pulsing Hubby Detector

This project uses an RF receiver module to trigger a pulsing LED Heart when the transmitter comes within range. I made this for my fiance for Valentine’s Day this year.

Pulsing Hubby Detector

I have yet to fully test the range, as I haven’t actually taken the transmitter out of our apartment building since I just finished it today. The transmitter/receiver pair that I used is hypothetically capable of up to 500 feet, though that is the open space line of sight range. I haven’t yet added antennas to either the receiver or transmitter box, but that should hypothetically improve the current range.

Step 1

Tools and Supplies

Tools Needed:

Soldering Iron
Dremel
Drill (or fairly large drill bit for the Dremel)
Screwdriver

Supplies
2 LEDs (1 red for the heart, another any color for a power light for the transmitter)
Printed Circuit Board (I used 276-159 from RadioShack)
2 5v Voltage Regulators (7805 or similar)
2 9v batteries
2 9v battery clips
2 project boxes (I used 270-1803 for the receiver, and a small 3x2x1 or so box for the transmitter)
2 SPST switches (I used 275-645)
2 8 pin DIP sockets (I used 276-1995)
2 PIC 12f683 (you can get a few of these as a free sample from Microchip)
2 Resistors (value depends on the LEDs you use, somewhere around 100ohms for typical LEDs from the 5v regulated voltage)
A small piece of plastic (preferably cloudy, or translucent)
wire
and last but most importantly
RF transmitter and receiver (I used RF-KLP-434 from Sparkfun, which was 11.95 for the pair)

Step 2

Breadboard Testing

RF transmitter and receiver

I set this up as a simple circuit on two breadboards (some people on the Sparkfun forums reported having problems getting the receiver/transmitter to work if they were only a few inches apart.)

The RF modules work fairly simply. You just provide them voltage (around 5v for the receiver, and up to 12v for the transmitter) and the signal on the transmitter’s data pin is replicated on the receiver.

In my circuit the data pin on the transmitter is being driven by an output on the PIC. I intend to work more on the PIC program to provide an actual data protocol, but in order to actually get this done this weekend, the transmitter PIC currently just sends a high signal for 500ms, then goes low for 500ms, and repeats as long as it’s switched on. There is an LED attached to the output pin to give a visual feedback of the pulse so you know the circuit is working.

The receiver is equally simple at present. The data pin goes to an input on the PIC. The PIC waits for a high signal, then pulses the LED as long as the signal is high. When the input signal is low, the PIC waits for 500ms, then polls the input again.

Here’s the code for now: *NOTE* The actual loop to make the LED pulse was taken from an example on the Sparkfun forums by user cheesy and just modified to make it run slower

Transmitter:
#include<12F683.h>

#use delay(clock=4000000,int=4000000)
#use fast_io(A)
#fuses nomclr

void main()
{
set_tris_a(0);
while(1) {
output_high(pin_a4);
delay_ms(500);
output_low(pin_a4);
delay_ms(500);
}
}

Receiver:
#include<12F683.h>

#use delay(clock=4000000,int=4000000)
#use fast_io(A)
#fuses nomclr

void main()
{
unsigned int i, j, k, step;
set_tris_a(0);
while(1) {
while (input(pin_a3)) {
step = 1;
j = 0;
do
{
for(; j < 100 && j >= 0; j += step)
{
for (k = 0; k < 10; k++)
{
OUTPUT_HIGH(PIN_A1);
for (i = j; i != 0; i–);
OUTPUT_LOW(PIN_A1);
for (i = 100-j; i != 0; i–);
}
}
step *= -1;
j += step;
} while (j > 0);
}
delay_ms(500);
}
}

Step 3

Assembly (pt 1)

I assembled the transmitter circuit first. The connections are fairly simple.

The +9v lead from the battery goes to the switch, which goes to both the transmitter (to run it straight from 9v) and the 7805 voltage regulator. The regulated voltage goes to the PIC.

Pin 2 of the PIC goes to the the LED (via a limiting resistor) and the Data pin of the transmitter.

When the switch is flipped on, the LED begins to blink (every 1/2 second) and the transmitter begins transmitting.

I’ve left the antenna pin unconnected for now, but I may add an antenna.

For more detail: Pulsing Hubby Detector using PIC12f683 microcontroller

 

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter