S
S
seregareal22016-06-18 17:59:09
Arduino
seregareal2, 2016-06-18 17:59:09

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
944a5690ca974b649c65f3d4aa27b018.PNG
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();
}
}

Documentation for my remote
Control buttons used (1 2 3 4)
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

3 answer(s)
A
Alexander Gusev, 2016-06-18
@seregareal2

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).

A
AntHTML, 2016-06-18
@anthtml

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.

S
seregareal2, 2016-06-18
@seregareal2

https://www.youtube.com/watch?v=nPEANUD9JQ4
https://arduino-info.wikispaces.com/IR-RemoteControl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question