-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduino
65 lines (52 loc) · 1.84 KB
/
Arduino
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
60
61
62
63
64
65
#### Elements used:
Arduino small DC motor
Development Board, Arduino Micro
IR Receiver
Mini Controller
Battery
5V Single Channel Relay Module
#### Instructions: Upload sketch, press 1 on the mini controller for the short period vibrations.
#### Sketch:
*
* Modified by Rui Santos, http://randomnerdtutorialscom
* based on IRremote Library - Ken Shirriff
*/
#include <IRremote.h>
int IR_Recv = 7; //IR Receiver Pin 3
int relayPin = 12; // int relayPin = 3;
int relayState = LOW; // int relayState = HIGH;
IRrecv irrecv(IR_Recv);
decode_results results;
void setup(){
Serial.begin(9600); //starts serial communication
irrecv.enableIRIn(); // Starts the receiver
pinMode(IR_Recv, INPUT);
digitalWrite(relayPin, relayState); // configure the initial state of relay
pinMode(relayPin, OUTPUT);
}
void loop(){
//decodes the infrared input
// Serial.println(relayState);
if (irrecv.decode(&results)){
long int decCode = results.value;
Serial.println(results.value);
//switch case to use the selected remote control button
switch (results.value){
case 16615543: //when you press the 2 button
//Serial.println(relayState);
relayState = LOW;
//Serial.println(relayState);
break;
case 16582903: //when you press the 1 button
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(12, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
//Serial.println(relayState);
break;
}
irrecv.resume(); // Receives the next value from the button you press
}
digitalWrite(relayPin, relayState);
delay(10);
}