Hi,
i made this program for a car project.
it is meant to control an l298n. the modul works but one of my conditions is always actived and i don't know why :
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
int moteur = 0;
int moteur1 =0;
int IN1 = 4;
int IN2 = 5;
int IN3 = 6;
int IN4 = 7;
void setup() {
Serial.begin(115200);
int moteur = 0;
int moteur1 =0;
radio.begin();
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1, addresses[1]);
radio.setPALevel(RF24_PA_MIN);
}
void loop() {
radio.startListening();
if ( radio.available()) {
while (radio.available()) {
;
radio.read(&moteur, sizeof(moteur));
if (moteur>104)
{
int moteur1 = map(moteur, 0, 200, 13, 255);
analogWrite(IN2, moteur1);
analogWrite(IN4, 0);
}
if (moteur<103)
{
int moteur1 = map(moteur, 0, 200, 13, 255);
analogWrite(IN2, 0);
analogWrite(IN4, 255);
}
Serial.println(moteur);
if (moteur=103){
analogWrite(IN2, 0);
analogWrite(IN4, 0);
Serial.println("STOP");
}
}
}
}
the very last "if" is always active, so it makes my motor don't work.
Without this "if" thing the motor works like i want to.
I don't understand cause when the value "moteur" is something else than 103, this "if" thing is activated.
I'm not native speaker so hope that i was clear enough.
Thanks