Created
June 27, 2017 15:03
-
-
Save kerimkaan/039f79d957ad7b1458f14e83f9bdc6ad to your computer and use it in GitHub Desktop.
Arduino ile IR Alıcı-Verici Kontrol Devresi Örneği
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Arduino ile IR Kontrolü | |
* | |
* IR alıcı 13. dijital pine bağlı | |
* Servo motor 9. dijital pine bağlı | |
* | |
* kerimkaan.com | |
* | |
*/ | |
#include <boarddefs.h> | |
#include <ir_Lego_PF_BitStreamEncoder.h> | |
#include <IRremote.h> | |
#include <IRremoteInt.h> | |
#include <Servo.h> | |
int RECV_PIN = 13; | |
IRrecv irrecv(RECV_PIN); | |
decode_results results; | |
Servo motor; | |
// Butonlar için HEX karşılıkları | |
#define BUTON1 0xFF30CF | |
#define BUTON2 0xFF18E7 | |
#define BUTON3 0xFF7A85 | |
void setup() { | |
Serial.begin(9600); | |
irrecv.enableIRIn(); | |
motor.attach(9); | |
} | |
void loop() { | |
if (irrecv.decode(&results)) | |
{ | |
if (results.value == BUTON1) | |
{ | |
Serial.println("1. Kademe / Step 1"); | |
motor.write(90); // 90 dereceye | |
delay(1000); // 1 saniye bekle | |
motor.write(0); // 0 dereceye | |
} | |
if (results.value == BUTON2) | |
{ | |
Serial.println("2. Kademe / Step 2"); | |
motor.write(90); // 90 dereceye | |
delay(1500); // 1.5 saniye bekle | |
motor.write(180); // 180 dereceye dön | |
} | |
if (results.value == BUTON3) | |
{ | |
Serial.println("3. Kademe/ Step 3"); | |
motor.write(180); // 180 dereceye git | |
delay(2000); // 2 saniye bekle | |
motor.write(270); // 279 dereceye dön | |
} | |
irrecv.resume(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment