i was making some programs for this but my motor doesn't work pleas help me!!!!
(i believe) this is the best program:
#include <IRremote.h>
int RECV_PIN = 9;
int motor1 = 7;
int motorpwm= 3;
int motor2 = 6;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the ir receiver
pinMode(motor1, OUTPUT);
pinMode(motor2, OUTPUT);
pinMode(motorpwm, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, DEC);
if(results.value == 2800){ //if you want to configure with your remote controll change the results.value
digitalWrite(motor1, HIGH); // set the LED on
digitalWrite(motor2, LOW);
if (irrecv.decode(&results)) {
Serial.println(results.value, DEC);
if(results.value == 2672)
digitalWrite(motor1, LOW); // set the LED off
digitalWrite(motor2, LOW);
irrecv.resume(); // Receive the next value
}
if(results.value == 752)
digitalWrite(motor1, HIGH); // set the LED on
digitalWrite(motor2, LOW);
if(results.value == 2672)
digitalWrite(motor1, LOW); // set the LED off
digitalWrite(motor2, LOW);
irrecv.resume(); // Receive the next value
}
}
analogWrite (motorpwm, 220);
}