IR transmitter not working with Arduino nano


This wiring

#include <IRremote.h>
#include "LowPower.h"

IRsend irsend;

const int b1 = 2;
const int b2 = 4;
const int b3 = 5;
const int b4 = 6;
const int b5 = 7;
const int b6 = 13;

int timer;
int modeCounter = 0;

void wakeUp() {
timer = 0;
}

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(b1, INPUT);
pinMode(b2, INPUT);
pinMode(b3, INPUT);
pinMode(b4, INPUT);
pinMode(b5, INPUT);
pinMode(b6, INPUT);
}

void loop() {
attachInterrupt(0, wakeUp, HIGH);
while (timer < 10000) {
if (digitalRead(b1) == HIGH) {
timer = 0;
delay(50);
irsend.sendNEC(0xA90, 32);
}

if (digitalRead(b2) == HIGH) {
  timer = 0;
  delay(50);
  irsend.sendNEC(0xC90, 32);
}

if (digitalRead(b3) == HIGH) {
  timer = 0;
  delay(50);
  irsend.sendNEC(0x90, 32);
}

if (digitalRead(b4) == HIGH) {
  timer = 0;
  delay(50);
  irsend.sendNEC(0x890, 32);
}

if (digitalRead(b5) == HIGH) {
  timer = 0;
  delay(50);
  irsend.sendNEC(0xEFE421, 32);
}
delay(1);
timer = timer + 1;

}

LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
}

Ir reciver work

Welcome to the forum!

Try adding the Send-Pin before including the IRRemote header file at the top of your sketch

#define IR_SEND_PIN 3
#include <IRRemote.h>

Look at the examples how to send NEC codes with the current library version.

Please edit your first post and enclose the whole code inside a single "code" tag to make it readable and let us copy it.

After add ir_send_pin 3 led continuously blinking
Without any key press

IRremote-4.1.2

Probably you have pulled up all the pins.
Post a pic of your actual connection

Temporary only 1 swtich connection.

I was asking for pic like this ↓

1 Like


Are you sure these two pins are interconnected?

Because your pins(4,5,7,13) are floating

You need to connect a pulldown resistor to pins 4,5,7

That button looks wrong to me.
When you soldered the pins (why?) you have lost the original shape, making hard to see what are the internally connected ones:
Push Button/Tactile Switch Pinout Connections, Uses ...

Based on your picture, it seems to me that the connections are like the red one I have drawn:

image

It means the input pin is always connected to +5V so it's always HIGH, thus the LED is always on transmitting the code.
So, in this case (you have here a single button) I suspect you just need to rotate the pushbutton position by 90 degrees.

Yes, or comment out everything about any button except the one he's using for test. :wink:

Push buttons are In square shape and identical from all sides. You can't determine which pins are interconnected by seeing a pic

It can be like this
IMG_20230511_133508

Or this
Screenshot_2023-05-11-13-34-50-61

Or in any other positions

Absolutely not. Pushbuttons are in a square case, yes, but to identificate the pins you must just look at the metallic legs: they come out from the plastic case on the same side, and no rotation can change that.
This means when looking them from the top you can clearly see pins 1 and 3 are the ones connected toghether, like 2 and 4, and you can recognize the pins despite any rotation:
image
image

For the OP, the problem could come out because he soldered some wire bits (I guess to make it easier to insert the button on the breadboard) and this makes the pins identification harder.

1 Like

Switch tested using multimeter both side ok
And all breadboard wire fitted ok

Tonight all reply testing

If you're having trouble with external resistors, try this

#include <IRremote.h>
#include "LowPower.h"

IRsend irsend;

const int b1 = 2;
const int b2 = 4;
const int b3 = 5;
const int b4 = 6;
const int b5 = 7;
const int b6 = 11;

int timer;
int modeCounter = 0;

void wakeUp() {
timer = 0;
}

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(b1, INPUT_PULLUP);
pinMode(b2, INPUT_PULLUP);
pinMode(b3, INPUT_PULLUP);
pinMode(b4, INPUT_PULLUP);
pinMode(b5, INPUT_PULLUP);
pinMode(b6, INPUT_PULLUP);
}

void loop() {
attachInterrupt(0, wakeUp, HIGH);
while (timer < 10000) {
if (digitalRead(b1) != HIGH) {
timer = 0;
delay(50);
irsend.sendNEC(0xA90, 32);
}

if (digitalRead(b2) != HIGH) {
  timer = 0;
  delay(50);
  irsend.sendNEC(0xC90, 32);
}

if (digitalRead(b3) != HIGH) {
  timer = 0;
  delay(50);
  irsend.sendNEC(0x90, 32);
}

if (digitalRead(b4) != HIGH) {
  timer = 0;
  delay(50);
  irsend.sendNEC(0x890, 32);
}

if (digitalRead(b5) != HIGH) {
  timer = 0;
  delay(50);
  irsend.sendNEC(0xEFE421, 32);
}
delay(1);
timer = timer + 1;
}

LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
}

Circuit diagram ↓

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.