Advertisement
charleston10

Carrinho de controle remoto

Aug 30th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <AFMotor.h>
  2. #include <IRremote.h>
  3.  
  4. int RECV_PIN = 2;
  5. IRrecv irrecv(RECV_PIN);
  6. AF_DCMotor motor(3, MOTOR12_1KHZ);
  7. AF_DCMotor motor2(4, MOTOR12_1KHZ);
  8.  
  9. decode_results results;
  10.  
  11. void setup() {
  12.     motor.setSpeed(255);
  13.     motor2.setSpeed(255);
  14.     irrecv.enableIRIn();
  15. }
  16.  
  17. void loop() {
  18.     if (irrecv.decode(&results)) {
  19.         if(results.value == 0×6621){
  20.             motor.run(FORWARD);
  21.             motor2.run(FORWARD);
  22.         }
  23.  
  24.         if(results.value == 0×2621){
  25.             motor.run(BACKWARD);
  26.             motor2.run(BACKWARD);
  27.         }
  28.  
  29.         if(results.value == 0×5621){
  30.             motor.run(FORWARD);
  31.             motor2.run(BACKWARD);
  32.         }
  33.  
  34.         if(results.value == 0×1621){
  35.             motor.run(BACKWARD);
  36.             motor2.run(FORWARD);
  37.         }
  38.  
  39.         irrecv.resume();
  40.     }
  41.  
  42.     delay(500);
  43.     motor.run(RELEASE);
  44.     motor2.run(RELEASE);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement