בשיעור היום נתרגל חיבור של מיקרובקר – וקליטה ושידור של שידור IR
נילמד להוסיף ספריה לקוד של ארדואינו – HX1838 model of IR Receiver.
נוסיף את הספריה
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include <IRremote.h> int RECV_PIN = 11; // Declare variables to hold pin number IRrecv irrecv(RECV_PIN); // Create irrecv object decode_results results; // declare variable to hold decoded IR receiver result void setup(){ // put your setup code here, to run once: Serial.begin(9600); //Initialize serial monitor Serial.println("Enabling IR Receiver"); // Print text on serial monitor irrecv.enableIRIn(); // Start the IR receiver Serial.println("Enabled IR Receiver"); // Print text on serial monitor } void loop() { // put your main code here, to run repeatedly: if (irrecv.decode(&results)) // Checks the code received or not { Serial.print("Decoded Signal = "); //Print text on serial monitor Serial.println(results.value); // Print the decoded value on serial monitor irrecv.resume(); // continue to receive the next value } delay(100); } |