Arduino Asked on November 13, 2021
#include <IRremote.h>
#include <AFMotor.h>
AF_DCMotor motor(1);
int RECV_PIN = 14;//The definition of the infrared receiver pin 11
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600); //Open serial
irrecv.enableIRIn(); // Initialization infrared receiver
motor.setSpeed(255);
motor.run(RELEASE);
Serial.println("start");
motor.run(FORWARD);
delay(1000);
}
void loop()
{
if (irrecv.decode(&results)) {
if(results.value==0x3D9AE3F7)
{
motor.run(FORWARD);
delay(2000);
}
else if(results.value==0x1BC0157B)
{
motor.run(RELEASE);
motor.run(BACKWARD);
}
Serial.println(results.value, HEX);//Wrap output in hex receive code
Serial.println();//For ease of viewing the output to add a blank line
irrecv.resume(); //Receiving the next value
}
}
Motor shield is not working when I use an IR receiver.
I tried connecting the ir receiver in different analog pins but it didn’t work. I guess it’s due to some error in my code but unable to figure out.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP