I Am Trying To Make My Ir Sensor Activate Pin 13 To Drive My Motor. However It Wont Do That No Matter What I Try.
I Get 2758 From Remote Decoder From This.
#include <IRremote.h>
const int RECV_PIN = 22;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
}
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
But It Wont Run My Motor
#include <IRremote.h>
int receiver = 22;
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results decodedSignal;
///
// Motor code
//Arduino PWM Speed Control?
int E1 = 3;
int M1 = 12;
int E2 = 11;
int M2 = 13;
///
void setup()
{
Serial.begin(9600);
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT);
pinMode(E1, OUTPUT);
pinMode(E2, OUTPUT);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
int value=255; //SPEED CONTOL
if (irrecv.decode(&decodedSignal)) // have we received an IR signal?
{
if (decodedSignal.value == 2758) { // Forwards
Serial.println("Forwords");
digitalWrite(M1,HIGH);
digitalWrite(M2,HIGH);
analogWrite(E1, value); //PWM Speed Control
analogWrite(E2, value); //PWM Speed Control
}
}
It Doesent even light up pin 13's Light?