Oups désolé 
Bon y a pas de secret ce code vient d'un projet deja existant sur le net, j'en ai d'autres équivalents et j'ai aussi remodelé mon propre code mais à la base c'est celui-ci:
/*
*/
#include <IRremote.h>
int RECV_PIN = 8; // IR Receiver - Arduino Pin Number 8
int pwmPin = 7; // Arduino Pin Number 7 to the Base of the Transistor
int pwmValue;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode( pwmPin, OUTPUT);
pwmValue = 0; // Starts the program with turned off motor
}
void loop() {
if (irrecv.decode(&results)) {
analogWrite(pwmPin, pwmValue);
if (results.value == 0xAFAF8374) { // PLAY Button
pwmValue = 255; // 100% Duty Cycle | Max Speed
}
if (results.value == 0x98519C65) { // STOP Button
pwmValue = 0; // 0% Duty Cycke | Turned off
}
if (results.value == 0x93F1BA08) { // FORWARD Button
if(pwmValue <= 245){
pwmValue = pwmValue + 10; // Increases the Duty Cycle of the PWM Signal
delay(20);
}
}
if (results.value == 0x71D086FF) { // BACKWARD Button
if(pwmValue >= 20){
pwmValue = pwmValue - 10; // Decreases the Duty Cycle of the PWM Signal
delay(20);
}
}
Serial.print(pwmValue);
Serial.print(" ");
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
delay(100);
}
Malheureusement ni celui-la ni aucun autre ne fonctionne.
Et pourtant le bete code simple pour varier la vitesse avec un potar fonctionne tres bien :
const int transistorPin = 3; // connected to the base of the transistor
void setup() {
Serial.begin(9600);
Serial.println("Allumage moteur");
// set the transistor pin as output:
pinMode(transistorPin, OUTPUT);
}
void loop() {
// read the potentiometer:
//int sensorValue = analogRead(A0);
int sensorValue = 100;
Serial.println(sensorValue);
// map the sensor value to a range from 0 - 255:
int outputValue = map(sensorValue, 0, 1023, 0, 255);
// use that to control the transistor:
analogWrite(transistorPin, outputValue);
}
Ce n'est pourtant qu' un simple analogWrite au départ, sauf que la on convertit la valeur du potentiometre et ca marche, alors que l'autre est le meme analogWrite mais la valeur injectée est codée suivant la touche de la télécommande IR, logiquement ca devrait fonctionner pareil?