From 6eb77fdf18616f79f99f2a57eed40d3b7a55eaa5 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 2 Jan 2017 09:24:18 +0100 Subject: Initial import --- .../infrared_Blink/infrared_Blink.ino | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 Lesson 3 Infrared Remote Control Car/infrared_Blink/infrared_Blink.ino (limited to 'Lesson 3 Infrared Remote Control Car/infrared_Blink') diff --git a/Lesson 3 Infrared Remote Control Car/infrared_Blink/infrared_Blink.ino b/Lesson 3 Infrared Remote Control Car/infrared_Blink/infrared_Blink.ino new file mode 100755 index 0000000..59560e7 --- /dev/null +++ b/Lesson 3 Infrared Remote Control Car/infrared_Blink/infrared_Blink.ino @@ -0,0 +1,35 @@ +//www.elegoo.com +//2016.09.12 + +#include //Infrared Library +int receiverpin = 12;//Infrared signal receiving pin +int LED=13; //define LED pin +volatile int state = LOW; //define default input mode +unsigned long RED; +#define L 16738455 +IRrecv irrecv(receiverpin);//initialization +decode_results results;//Define structure type +void setup() { +pinMode(LED, OUTPUT); //initialize LED as an output +Serial.begin(9600); // debug output at 9600 baud + irrecv.enableIRIn();// Start receiving +} +void stateChange() +{ + state = !state; + digitalWrite(LED, state); +} +void loop() { +if (irrecv.decode(&results)) + { + RED=results.value; + Serial.println(RED); + irrecv.resume(); // Receive the next value + delay(150); + if(RED==L) + { + stateChange(); + } + } + } + -- cgit v1.2.3