SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <AFMotor.h> | |
| 2 | #include <IRremote.h> | |
| 3 | #define irPin 2 | |
| 4 | ||
| 5 | IRrecv irrecv(irPin); | |
| 6 | decode_results results; | |
| 7 | AF_DCMotor motor(4); | |
| 8 | AF_DCMotor motor1(3); | |
| 9 | ||
| 10 | int counter = 0; | |
| 11 | ||
| 12 | void setup() {
| |
| 13 | Serial.begin(9600); | |
| 14 | irrecv.enableIRIn(); | |
| 15 | ||
| 16 | motor.setSpeed(200); | |
| 17 | motor1.setSpeed(200); | |
| 18 | motor.run(RELEASE); | |
| 19 | motor1.run(RELEASE); | |
| 20 | } | |
| 21 | ||
| 22 | void loop() {
| |
| 23 | if (irrecv.decode(&results)) {
| |
| 24 | ||
| 25 | switch (results.value) {
| |
| 26 | case 0xFF629D: | |
| 27 | - | motor.run(FORWARD); |
| 27 | + | |
| 28 | motor.run(FORWARD); | |
| 29 | motor1.run(FORWARD); | |
| 30 | - | |
| 30 | + | counter = 0; |
| 31 | break; | |
| 32 | ||
| 33 | - | switch (results.value) {
|
| 33 | + | |
| 34 | Serial.println("jazda w tyl");
| |
| 35 | motor.run(BACKWARD); | |
| 36 | - | motor.run(BACKWARD); |
| 36 | + | |
| 37 | counter = 0; | |
| 38 | break; | |
| 39 | ||
| 40 | - | switch (results.value) {
|
| 40 | + | |
| 41 | Serial.println("jazda w prawo");
| |
| 42 | motor.run(BACKWARD); | |
| 43 | - | motor.run(BACKWARD); |
| 43 | + | |
| 44 | counter = 0; | |
| 45 | break; | |
| 46 | ||
| 47 | - | switch (results.value) {
|
| 47 | + | |
| 48 | Serial.println("jazda w lewo");
| |
| 49 | motor.run(FORWARD); | |
| 50 | - | motor.run(FORWARD); |
| 50 | + | |
| 51 | counter = 0; | |
| 52 | break; | |
| 53 | ||
| 54 | - | switch (results.value) {
|
| 54 | + | |
| 55 | Serial.println("sTOP");
| |
| 56 | motor.run(RELEASE); | |
| 57 | - | motor.run(RELEASE); |
| 57 | + | |
| 58 | break; | |
| 59 | } | |
| 60 | irrecv.resume(); | |
| 61 | } | |
| 62 | ||
| 63 | if(counter == 50) | |
| 64 | {
| |
| 65 | motor.run(RELEASE); | |
| 66 | motor1.run(RELEASE); | |
| 67 | } | |
| 68 | ||
| 69 | counter++; | |
| 70 | } |