hello I'm trying to control two different motors at two diffent speeds and was wondering if anyone could help me out right now I have one speed for both motors... here is my code...
#include <IRremote.h>
int RECV_PIN = 4;
IRrecv irrecv(RECV_PIN);
decode_results results;
int pinI1=8;//define I1 interface // UP DOWN MOTOR
int pinI2=11;//define I2 interface
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface // FORWARD BACKWARD MOTOR
int pinI4=13;//define I4 interface
int speedpinB=10;//enable motor B
int spead =37;//define the spead of motor
void setup()
{
irrecv.enableIRIn();
pinMode(pinI1,OUTPUT);// UP DOWN MOTOR
pinMode(pinI2,OUTPUT);
pinMode(speedpinA,OUTPUT);
pinMode(pinI3,OUTPUT);// FORWARD BACKWARD MOTOR
pinMode(pinI4,OUTPUT);
pinMode(speedpinB,OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
irrecv.resume();
if (results.value == 0x827D40BF){ // forward
//SPEED
analogWrite(speedpinB,spead);
digitalWrite(pinI4,HIGH);
digitalWrite(pinI3,LOW);
}else if(results.value == 0x827DC03F){ // UP
analogWrite(speedpinA,spead);//SPEED
digitalWrite(pinI2,LOW);
digitalWrite(pinI1,HIGH);
}
else if(results.value == 0x827D807F){ // DOWN
analogWrite(speedpinA,spead);//SPEED
digitalWrite(pinI2,HIGH);
digitalWrite(pinI1,LOW);
}
else if(results.value == 0x827D10EF){ // BACKWARD
analogWrite(speedpinB,spead);//SPEED
digitalWrite(pinI4,LOW);
digitalWrite(pinI3,HIGH);
}
else if(results.value == 0x827DA05F){ // STOP
digitalWrite(speedpinA,LOW);
digitalWrite(speedpinB,LOW);
}
}
}