52 lines
888 B
Plaintext
52 lines
888 B
Plaintext
/*
|
|
Progetto di scacciazanzare basato su PIC16C84
|
|
*/
|
|
#include <pic.h>
|
|
#include "delay.h"
|
|
|
|
__CONFIG(FOSC0|UNPROTECT);
|
|
|
|
static bit LED @ ((unsigned)&PORTB*8+3); // RB3: LED...
|
|
static bit SPK1 @ ((unsigned)&PORTB*8+4); // RB4: Speaker +
|
|
static bit SPK2 @ ((unsigned)&PORTA*8+2); // RA2: Speaker -
|
|
|
|
|
|
#define LED_ON (LED=0);
|
|
#define LED_OFF (LED=1);
|
|
|
|
void sound(void){
|
|
unsigned char lambda=80;
|
|
unsigned char i;
|
|
do{
|
|
for(i=0;i<4;i++){
|
|
SPK1=0;
|
|
SPK2=0;
|
|
DelayUs(lambda);
|
|
SPK1=1;
|
|
SPK2=0;
|
|
DelayUs(lambda);
|
|
SPK1=0;
|
|
SPK2=0;
|
|
DelayUs(lambda);
|
|
SPK1=0;
|
|
SPK2=1;
|
|
DelayUs(lambda);
|
|
}
|
|
lambda--;
|
|
}while (lambda>10);
|
|
}
|
|
|
|
void main (void){
|
|
TRISA=0x00; // tutto output
|
|
TRISB=0x00;
|
|
PORTA=0xff; // tutte le uscite ad 1
|
|
PORTB=0xff;
|
|
do{
|
|
//sound();
|
|
DelayMs(200);
|
|
LED_ON;
|
|
DelayMs(200);
|
|
LED_OFF;
|
|
}while (1);
|
|
}
|