-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTx_20191_interuptVer20.ino
59 lines (40 loc) · 1.47 KB
/
Tx_20191_interuptVer20.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <RCSwitch.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/power.h>
RCSwitch mySwitch = RCSwitch();
const byte interruptPin = 0;
const int PowerRF = 3;
const int DataPin = 4;
void TransmitCode(int Code){
digitalWrite(PowerRF,HIGH); //Power on, for the 433Mhz module
for (int i = 0; i <= 1; i++) { //Repeat 2 times
mySwitch.send(Code, 24);
delay(500); //Wait 800ms
}
digitalWrite(PowerRF,LOW); //Power off, for the 433Mhz module
}
void SleepAll() {
delay(100);
sei(); // enables interrupts
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
power_all_disable (); // power off ADC, Timer 0 and 1, serial interface
sleep_enable();
sleep_mode();
sleep_disable();
power_all_enable ();
}
void setup() {
pinMode(PowerRF,OUTPUT);
GIMSK |= (1 << PCIE); // pin change interrupt enable
PCMSK |= (1 << PCINT0);
ADCSRA = 0; // ADC uses ~320uA
mySwitch.enableTransmit(DataPin); // Datapin on P4
}
void loop() {
SleepAll();
TransmitCode(20191);
}
ISR(PCINT0_vect) {
// nothing to do
}