/* Program written by: R Jordan Kreindler Date: Dec 11, 2020 Sketch decodes IR remote values to turn on red, yellow, and green 10mm LEDs and to turn them off */ // Include the built-in library IRremote by Ken Shiffiff #include //Establish IR receiver pin byte receiverPin = 6; //Set-up LED pins byte redLED = 8; byte yellowLED = 9; byte greenLED = 10; // Establish delay times for LEDs int delay1 = 10000; // Create the IR receiver object // Here I use the name IRReceiver IRrecv IRReceiver(receiverPin); // Store the results of our receive value in results decode_results results; unsigned long IRValueReceived; void setup() { // Set LEDs for Output pinMode(redLED ,OUTPUT); pinMode(yellowLED,OUTPUT); pinMode(greenLED ,OUTPUT); // Start the Serial Monitor at 9600 baud Serial.begin(9600); // Enable the timer interrupt IRReceiver.enableIRIn(); } void loop() { if (IRReceiver.decode(&results)) { // Execute when an IR signal is received IRValueReceived = results.value; if (IRValueReceived == 3772784863) { // Turn red LED on Serial.println("RED On"); digitalWrite(redLED, HIGH); delay(delay1); digitalWrite(redLED, LOW); // Turn red LED off } if (IRValueReceived == 3772817503) { // Turn yellow LED on Serial.println("Yellow On"); digitalWrite(yellowLED, HIGH); delay(delay1); digitalWrite(yellowLED, LOW); // Turn yellow LED off } if (IRValueReceived == 3772801183) { // Turn green LED on Serial.println("Green On"); digitalWrite(greenLED, HIGH); delay(delay1); digitalWrite(greenLED, LOW); // Turn green LED off } if (IRValueReceived == 3772780783) { // turn all LEDs on Serial.println("All On"); digitalWrite(redLED , HIGH); digitalWrite(yellowLED, HIGH); digitalWrite(greenLED , HIGH); delay(delay1); digitalWrite(redLED , LOW); // Turn all LEDs off digitalWrite(yellowLED, LOW); digitalWrite(greenLED , LOW); } IRReceiver.resume(); // Await next IR code } }