hi. i want to press “unu” button of the remote, and the motor to rotate continuously, and when i press “sound” i want the motor to rotate untill the hall sensor detects a magnetic field. any ideas please?
#include <TLE94112.h>
#include <Tle94112Motor.h>
#include <IRremote.h>
#define unu 0x1
#define sound 0x55
int RECV_PIN = 2;
int hallSensorPin1 = 3;
int state1;
int oldState1 = 1;
Tle94112 controller = Tle94112();
Tle94112Motor motor1(controller);
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{ irrecv.enableIRIn();
controller.begin();
motor1.connect(motor1.HIGHSIDE, controller.TLE_HB1);
motor1.connect(motor1.LOWSIDE, controller.TLE_HB2);
motor1.setPwm(motor1.HIGHSIDE, controller.TLE_PWM2);
motor1.setPwmFreq(motor1.HIGHSIDE, controller.TLE_FREQ200HZ);
motor1.begin();
}
void loop()
{
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume();
if(results.value==unu||results.value==0x801||results.value==0x2049){
motor1.start(63);
}
if(results.value==sound||results.value==0x55||results.value==0x2103||results.value==0x837||results.value==0x37){
motor1.start(63);}
}
state1 = digitalRead(hallSensorPin1);
if (state1 == HIGH) {
oldState1 = 1;
}
if (state1 == LOW && oldState1 == 1) {
motor1.coast();
oldState1 = 0;
}
}