Hi, I was wondering how I can use an IR receiver to control the L293D motor control shield
Thank You, cubingmaster10233
Hi, I was wondering how I can use an IR receiver to control the L293D motor control shield
Thank You, cubingmaster10233
You can do so by adding IR Receiver module and then getting IR remote code and adding that code in case and in case your action that if you press the button what to do.
Here is the small code for your help
#include <IRremote.h>
#include <AFMotor.h>
AF_DCMotor motor1(1);
IRrecv irrecv(2);
decode_results results;
void setup()
{
Serial.begin(9600);
motor1.setSpeed(255);
irrecv.enableIRIn();
}
void loop()
{
if (irrecv.decode(&results))
{
switch(results.value)
{
case 0xFF30CF:
// Code for button "1" on the IR remote
motor1.run(FORWARD);
break;
case 0xFF18E7:
// Code for button "2" on the IR remote
motor1.run(BACKWARD);
break;
case
You can also visit my channel for more detail on this
Using the following link CLICK HERE
Thanks, But the code had this error message:
/usr/local/bin/arduino-cli compile --fqbn arduino:avr:uno --libraries /home/builder/opt/libraries/latest --build-cache-path /tmp --output-dir /tmp/214551648/build --build-path /tmp/arduino-build-6C7BFECBE6D158DB61AD1963FB213E0B --library /mnt/create-efs/webide/a1/c1/a1c1a170b2b847dcfe6dbea0f8bc260a:brobro10233/libraries_v2/Adafruit Motor Shield library --library /mnt/create-efs/webide/a1/c1/a1c1a170b2b847dcfe6dbea0f8bc260a:brobro10233/libraries_v2/IRremote /tmp/214551648/sketch_mar23a
Using library IRremote at version 4.1.2 in folder: /mnt/create-efs/webide/a1/c1/a1c1a170b2b847dcfe6dbea0f8bc260a:brobro10233/libraries_v2/IRremote
Using library Adafruit Motor Shield library at version 1.0.1 in folder: /mnt/create-efs/webide/a1/c1/a1c1a170b2b847dcfe6dbea0f8bc260a:brobro10233/libraries_v2/Adafruit Motor Shield library
/tmp/214551648/sketch_mar23a/sketch_mar23a.ino: In function 'void loop()':
/tmp/214551648/sketch_mar23a/sketch_mar23a.ino:29:7: error: expected primary-expression at end of input
case
^~~~
/tmp/214551648/sketch_mar23a/sketch_mar23a.ino:29:7: error: expected ':' at end of input
/tmp/214551648/sketch_mar23a/sketch_mar23a.ino:29:7: error: expected statement at end of input
/tmp/214551648/sketch_mar23a/sketch_mar23a.ino:29:7: error: expected '}' at end of input
/tmp/214551648/sketch_mar23a/sketch_mar23a.ino:29:7: error: expected '}' at end of input
/tmp/214551648/sketch_mar23a/sketch_mar23a.ino:29:7: error: expected '}' at end of input
Error during build: exit status 1
Thanks, brobro10233
Kindly check the following:-
Do you install all the liabries which are required
Have you changed the things as you want
Try this update code
#include <IRremote.h>
#include <AFMotor.h>
AF_DCMotor motor1(1);
IRrecv irrecv(2);
decode_results results;
void setup()
{
Serial.begin(9600);
motor1.setSpeed(255);
irrecv.enableIRIn();
}
void loop()
{
if (irrecv.decode(&results))
{
switch(results.value)
{
case 0xFF30CF:
// Code for button "1" on the IR remote
motor1.run(FORWARD);
break;
case 0xFF18E7:
// Code for button "2" on the IR remote
motor1.run(BACKWARD);
break;
case
}
}
}
The code still doesn't work. The code is:
#include <AFMotor.h>
AF_DCMotor motor1(1);
IRrecv irrecv(2);
decode_results results;
void setup()
{
Serial.begin(9600);
motor1.setSpeed(255);
irrecv.enableIRIn();
}
void loop()
{
if (irrecv.decode(&results))
{
switch(results.value)
{
case 0xFF30CF:
// Code for button "1" on the IR remote
motor1.run(FORWARD);
break;
case 0xFF18E7:
// Code for button "2" on the IR remote
motor1.run(BACKWARD);
break;
case
}
}
}
And the error message is:
/private/var/folders/p8/3fjvvldj68nbpgnd6ys1r89r0000gp/T/.arduinoIDE-unsaved2023225-5074-11okn01.bi34h/sketch_mar25a/sketch_mar25a.ino:30:5: error: expected primary-expression before '}' token
}
^
/private/var/folders/p8/3fjvvldj68nbpgnd6ys1r89r0000gp/T/.arduinoIDE-unsaved2023225-5074-11okn01.bi34h/sketch_mar25a/sketch_mar25a.ino:30:5: error: expected ':' before '}' token
/private/var/folders/p8/3fjvvldj68nbpgnd6ys1r89r0000gp/T/.arduinoIDE-unsaved2023225-5074-11okn01.bi34h/sketch_mar25a/sketch_mar25a.ino:30:5: error: expected primary-expression before '}' token
exit status 1
Compilation error: expected primary-expression before '}' token
Thanks
This is just example code you have to change it as per your requirement
Also it is not possible to guide you properly without your code, circuit diagram, and project use
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.