#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
}
}
}
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
Delay_ms(100) ; // wait 100 ms
}
TRISA1=1; // RA1 is switch input
TRISD6=0; // RD6 is LED output
TRISD5=0; // RD5 is LED output
RD6=1; // set LED
while(1)
{
RD5=RA1; // copy sw2 to LED
RD6=!RD6; // invert LED to blink it
// check for received character and echo it
while(uartReceived()) putchar(getchar());
tenthsSecondDelay(10); // delay for a second
}
}
if (PORTA.f0)
if(RA1)
{
#include "16f628a.h"
void main(void) {
[COLOR="red"] CMCON = 0x07; // switch off comparators; it is a must to use porta for input[/COLOR]
// set portA as inputs
TRISA = [COLOR="red"]3; // bin 11, NOT 1 !!; set porta.0 [B]AND porta.1[/B] as inputs,[/COLOR]
// set portB as outputs
TRISB = 0;
[COLOR="red"]PORTB = 0; init portb, all leds off at start[/COLOR]
for(;;) { // forever
if (PORTA.f0) { // if there's a trigger pulse [COLOR="red"]on porta.0[/COLOR]
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 an trigger pulse [COLOR="red"]on porta.1[/COLOR]
PORTB.f1 = 1; // turn the LED on
Delay_ms(100) ; // wait 100 ms
PORTB.f1 = 0; // turn led off
}
}
}
PORTB.f0 = 0; // turn led off
break;
thank youOK, good luck!
- your scope HAS an 1M input resistance ...
yes, you're right... Infact the actual mode isn't so "efficient", particularly when the hits on the drum are very fast...This task is an example of what must be resolved using interrupts .
inTRISA = 3;
TRISA = 0xFF;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?