Hey everyone! I just bought an Elegoo Starter Kit with an Uno R3, and I am new to code and Arduino IDE. I need help on a school project I am working on and need help programming a motor to spin based off an IR remote signal.
#include <IRLib.h>
#define skipLeft 0x52A3D41F
#define skipRight 0x20FE4DBB
int motor = 4;
IRrecv Receiver(11);
IRdecode Decoder;
void setup() {
// put your setup code here, to run once:
Receiver.enableIRIn();
}
void loop() {
// put your main code here, to run repeatedly:
if (Receiver.GetResults(&Decoder))
{
Decoder.decode();
switch (Decoder.value)
{
case skipLeft: digitalWrite(motor, LOW); break;
case skipRight: digitalWrite(motor, HIGH); break;
}
}
Receiver.resume();
}
Pretty much what I am wondering is if it is possible to click a button on the IR remote, and have it be programmed to run the motor until I click another button that is programmed to stop it. What would I need to change with the code to allow this?
Thank you in advance!