Circuit wiring :
Project parts :
To realize this project you will need :
- 1 Arduino Uno.
- 1 Breadboard.
- 1 IR Receiver Sensor ( TSOP38238).
- 1 Mini Remote Control.
- 1 Servo Motor.
- Connector wires.
Wiring :
Code
#include <IRremote.h>
#include <Servo.h>
int RECV_PIN = 5;
Servo servo;
IRrecv irrecv(RECV_PIN);
decode_results results;
int i=0;
void setup() {
servo.attach(9);
servo.write(0);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if(irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if(results.value == 0xFD609F){
i+=10;
servo.write(i);
delay(200);
}
if(results.value == 0xFD20DF){
i-=10;
servo.write(i);
delay(200);
}
irrecv.resume();
}
delay(50);
}
#include <Servo.h>
int RECV_PIN = 5;
Servo servo;
IRrecv irrecv(RECV_PIN);
decode_results results;
int i=0;
void setup() {
servo.attach(9);
servo.write(0);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if(irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if(results.value == 0xFD609F){
i+=10;
servo.write(i);
delay(200);
}
if(results.value == 0xFD20DF){
i-=10;
servo.write(i);
delay(200);
}
irrecv.resume();
}
delay(50);
}
No comments:
Post a Comment