Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <16F886.h>
- #device ADC=10 *=16
- #FUSES NOWDT //No Watch Dog Timer
- #FUSES PUT //Power Up Timer
- #FUSES NOMCLR //Master Clear pin not enabled
- #FUSES NOPROTECT //Code not protected from reading
- #FUSES NOCPD //No EE protection
- #FUSES BROWNOUT //Brownout reset
- #FUSES IESO //Internal External Switch Over mode enabled
- #FUSES FCMEN //Fail-safe clock monitor enabled
- #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
- #FUSES NODEBUG //No Debug mode for ICD
- #FUSES NOWRT //Program memory not write protected
- #FUSES BORV40 //Brodddddwnout reset at 4.0V
- #FUSES RESERVED //Used to set the reserved FUSE bits
- #FUSES INTRC_IO
- #use delay(clock=8M)
- #define SLAVE_ADDRESS 0xB0
- //#define SLAVE_ADDRESS 0xD0
- #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
- #use i2c(MASTER, I2C1, FORCE_HW) // configure the i2c port
- int counter=0;
- int counter2=0;
- int duty=0;
- int y=1;
- int pwd=1;
- int pwd2=1;
- #INT_TIMER1
- void timer1_isr(){
- set_timer1(65036);
- counter++;
- counter2++;
- if (counter == 19) { counter = 0;}
- if (counter == 0) {
- output_high(PIN_B4);} // beginning of a new period
- if (counter2 == 19) { counter2 = 0;}
- if (counter2 == 0) {
- output_high(PIN_B4);} // beginning of a new period
- if (counter == pwd) {output_low(PIN_B4);}
- if(counter2 == pwd2){output_low(PIN_B3);}
- }
- void main() {
- setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
- set_timer1(65036);
- enable_interrupts(INT_TIMER1);
- enable_interrupts(GLOBAL);
- //Counter = 0;
- // Duty = 3;
- While(1){
- if (!input(PIN_B7) && y==1) {
- output_high(PIN_B5);
- delay_ms(1000);
- if(pwd==1){
- pwd=2;
- output_low(PIN_B5);
- }else{
- pwd=1;
- //output_high(PIN_B5);
- }
- if(pwd2==2){
- pwd2=1;
- output_low(PIN_B5);
- }else{
- pwd2=2;
- //output_high(PIN_B5);
- }
- y=0;
- delay_ms(200);
- }else{
- y=1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement