From 5a32c0c9a493510f5469cb4ad2c314797b699009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sat, 2 Aug 2014 15:56:11 -0700 Subject: [PATCH] use relay to signal new saved code --- pic/MDR/MDR.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pic/MDR/MDR.c b/pic/MDR/MDR.c index 37d2038..dbbc75e 100644 --- a/pic/MDR/MDR.c +++ b/pic/MDR/MDR.c @@ -76,6 +76,7 @@ void init (void) { ANSELB = 0; /* all pins are digital */ TRISA |= RADIO; /* radio signal is an input */ TRISA &= ~(RELAY1|RELAY2); /* relays are outputs */ + LATA &= ~(RELAY1|RELAY2); /* switch relays off */ TRISB |= SWITCH1|SWITCH2; /* switches are inputs (with external pull-ups) */ TRISB &= ~(LED); /* LED is an output (used a sink) */ led_off(); /* starting state */ @@ -274,8 +275,8 @@ static void interrupt(void) __interrupt 0 switches ^= PORTB; /* figure out which switch changed */ if (switches&SWITCH1) { /* switch 1 changed */ if (PORTB&SWITCH1) { /* switch 1 released */ + clear_memory(); /* empty saved codes */ led_off(); /* reset LED */ - clear_memory(); } else { /* switch 1 pressed */ led_on(); /* test LED */ } @@ -340,8 +341,13 @@ void main (void) } if (bit==24) { /* received all 24 bits */ led_on(); - save_code(); /* save code in external EEPROM */ + new = save_code(); /* save code in external EEPROM */ led_off(); + if (new==1) { /* new code saved */ + LATA |= RELAY1; /* switch relay on */ + for (new=0; new<1024; new++); /* wait a bit */ + LATA &= ~RELAY1; /* switch relay off */ + } } } if (bit==0) { /* sync pulse (can be the current one it it is not a continuation */