gutisie
Junior Member level 1
PIC 10F220
Dear All;
My name is GUTI, I have started programing PICS, I find them interesting, but I have very little understanding of them.
I have some pdfs that are very help ful but I am a bit stuck at the moment.
I am able to blink the led, thats no problem. But now I am trying to do som debouncing code to count the number of time a ir barrier is broken by the passing object.
I have the pic 10f220 conected in port gp0 the ir emitter from an old ball mouse, and on port gp3 the ir receiver. So thats the ir barrier.
On port gp1 I have a mosfet gate conected. This mosfet will drive a dc motor.
The idea is when it counts 3 objects (3 times the ir barrier is broken), the gp1 goes low for 1 second. And then starts again.
More or less this is my code at the moment, but I have no clue what so ever of how it goes.
I am using ccs pcb compiler with mplab 8.5
Any help much appreciated.
Best regards.
CODE:
#include <10F220.h>
#define GP0 PIN_B0
#define GP1 PIN_B1
#define GP2 PIN_B2
#define GP3 PIN_B3
#use delay (clock=4000000) //frecuencia
//for some reason fuses dont work, so i delete this line
#fuses MCLR,NOPROTECT,NOWDT,INTRC
void main()
{
while (TRUE) {
output_high(GP0); //ir led on
output_high(GP1); //mosfet on
And i dont know how to finish...now i should count upto 3 interrupts and then make low GP1, for 1 second and repeat loop, but I dont know how....
Any help much appreciated.
Thanks.
Dear All;
My name is GUTI, I have started programing PICS, I find them interesting, but I have very little understanding of them.
I have some pdfs that are very help ful but I am a bit stuck at the moment.
I am able to blink the led, thats no problem. But now I am trying to do som debouncing code to count the number of time a ir barrier is broken by the passing object.
I have the pic 10f220 conected in port gp0 the ir emitter from an old ball mouse, and on port gp3 the ir receiver. So thats the ir barrier.
On port gp1 I have a mosfet gate conected. This mosfet will drive a dc motor.
The idea is when it counts 3 objects (3 times the ir barrier is broken), the gp1 goes low for 1 second. And then starts again.
More or less this is my code at the moment, but I have no clue what so ever of how it goes.
I am using ccs pcb compiler with mplab 8.5
Any help much appreciated.
Best regards.
CODE:
#include <10F220.h>
#define GP0 PIN_B0
#define GP1 PIN_B1
#define GP2 PIN_B2
#define GP3 PIN_B3
#use delay (clock=4000000) //frecuencia
//for some reason fuses dont work, so i delete this line
#fuses MCLR,NOPROTECT,NOWDT,INTRC
void main()
{
while (TRUE) {
output_high(GP0); //ir led on
output_high(GP1); //mosfet on
And i dont know how to finish...now i should count upto 3 interrupts and then make low GP1, for 1 second and repeat loop, but I dont know how....
Any help much appreciated.
Thanks.