vaka85
Advanced Member level 4
Hi all,
I'm a beginner in pic programming, and I'd like to blink a led (a fast flash) everytime there is an input (a piezo buzzer connected in the pic inputs).
Here is the code, I'm using mikroc:
The output part should be fine, because I've used it in another project... but the input one?
I've checked with an oscilloscope and the external trigger is ok..
Could you tell me where I'm wrong?
Thanks
I'm a beginner in pic programming, and I'd like to blink a led (a fast flash) everytime there is an input (a piezo buzzer connected in the pic inputs).
Here is the code, I'm using mikroc:
Code:
#include "16f628a.h"
void main(void) {
// set portA as inputs
TRISA = 1;
// set portB as outputs
TRISB = 0;
for(;;) // forever
{
if (PORTA.f0) // if there's a trigger pulse
{
PORTB.f0 = 1; // turn the LED on
Delay_ms(100) ; // wait 100 ms
PORTB.f0 = 0; // turn led off
}
if (PORTA.f1) // if there's a trigger pulse
{
PORTB.f1 = 1; // turn the LED on
Delay_ms(100) ; // wait 100 ms
PORTB.f1 = 0; // turn led off
}
}
}
The output part should be fine, because I've used it in another project... but the input one?
I've checked with an oscilloscope and the external trigger is ok..
Could you tell me where I'm wrong?
Thanks