Counter in PIC 16f877a

Thread Starter

QMD

Joined Jun 30, 2010
30
I am trying to implement a counter using a PIC16F877A

I have a proximity sensor which will only output high when an object is within a certain range (I have set this range in the pic based on the output voltage of the rangefinder)

I have a variable (double) x, which I set to increment every time the conditions are met. After I reach 5, I then wish for an LED to turn on. I tried this, but the LED is always on...and sometimes flickers.....any idea what the issue is?

Thanks
 

someonesdad

Joined Jul 7, 2009
1,583
You need to show your hardware connections (i.e., a schematic) and your software. Not doing so is kinda like saying "My car won't run -- what's wrong with it". :p

By "(double)", do you mean you're programming in C? If so, why are you using a double for something that is inherently an integer?
 

Thread Starter

QMD

Joined Jun 30, 2010
30
Sorry for the lack of clarity...
I am programming the PIC using C...but I figured out my problem...I needed to put a delay after each count. Since I am oscillating at 20mHz, it counts many times for each time a human perceives a count
 
Top