Answer the question
In order to leave comments, you need to log in
How to make friends Arduino with IR remote control?
Who knows what the problem is, the motor does not turn off after turning on, but the LED turns on and off?
Also, after turning on the motor, the LED does not turn on and off
, maybe because of the diode?
and the IR module is buggy when the motor is turned on, the video shows
the code itself
#include <IRremote.h>
int RECV_PIN = 2; //вход ИК приемника
IRrecv irrecv(RECV_PIN);
decode_results results;
int LED = 13;
int motorPin = 8;
void setup()
{
irrecv.enableIRIn(); // включить приемник
pinMode(LED, OUTPUT);
pinMode(motorPin, OUTPUT);
}
void loop() {
if (irrecv.decode(&results))
{
if (results.value == 0xFF6897)
{
digitalWrite(LED, HIGH);
}
if (results.value == 0xFF9867)
{
digitalWrite(LED, LOW);
}
if (results.value == 0xFFB04F)
{
digitalWrite(motorPin, HIGH);
}
if (results.value == 0xFF30CF)
{
digitalWrite(motorPin, LOW);
}
irrecv.resume();
}
}
case 0xFF6897: Serial.println(" 1"); break;
case 0xFF9867: Serial.println(" 2"); break;
case 0xFFB04F: Serial.println(" 3"); break;
case 0xFF30CF: Serial.println(" 4"); break;
Answer the question
In order to leave comments, you need to log in
Connect the engine not to + 5V, but to Vin - this will exclude the fact that the power is draining and the arduin is stupid (when the servo is powered from +5 arduina, it twitches in convulsions, and the controller is stupid, when the servo is powered from Vin everything is ok).
There may also be strong interference if the currents in the motor are large, in which case try to space the power and control devices away from each other; protect the controller with foil planted on a common wire. (well, if you really turn on something powerful).
If, after turning on the motor, everything starts to fail, then it is necessary to separate the power supply of the motor and the logic part as far as possible, and put a more capacious capacitor in the logic power circuit, because. most likely the motor currents and give interference.
https://www.youtube.com/watch?v=nPEANUD9JQ4
https://arduino-info.wikispaces.com/IR-RemoteControl
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question