Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <AFMotor.h>
- #include <IRremote.h>
- #define irPin 2
- IRrecv irrecv(irPin);
- decode_results results;
- AF_DCMotor motor(4);
- AF_DCMotor motor1(3);
- void setup() {
- Serial.begin(9600);
- irrecv.enableIRIn();
- motor.setSpeed(200);
- motor1.setSpeed(200);
- motor.run(RELEASE);
- motor1.run(RELEASE);
- }
- void loop() {
- if (irrecv.decode(&results)) {
- switch (results.value) {
- case 0xFF629D:
- Serial.println("jazda w przod");
- motor.run(FORWARD);
- motor1.run(FORWARD);
- break;
- }
- switch (results.value) {
- case 0xFF6897:
- Serial.println("jazda w tyl");
- motor.run(BACKWARD);
- motor1.run(BACKWARD);
- break;
- }
- switch (results.value) {
- case 0xFFA857:
- Serial.println("jazda w prawo");
- motor.run(BACKWARD);
- motor1.run(FORWARD);
- break;
- }
- switch (results.value) {
- case 0xFFE21D:
- Serial.println("jazda w lewo");
- motor.run(FORWARD);
- motor1.run(BACKWARD);
- break;
- }
- switch (results.value) {
- case 0xFFE817:
- Serial.println("sTOP");
- motor.run(RELEASE);
- motor1.run(RELEASE);
- break;
- }
- irrecv.resume();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement