can someone help me with this

i am making a code for ir signals but when i press the button it doesn’t want to send the ir signal to pin 11~

#include <IRremote.h>

int buttonPin = 8;
int ledPin = 13;

IRsend ir;
char dato;

unsigned int  rawData[67] = {4500,4500, 500,1700, 550,1700, 500,1700, 550,600, 500,600, 500,550, 600,550, 550,600, 500,1650, 550,1750, 500,1700, 500,600, 550,600, 500,600, 500,600, 550,550, 550,600, 500,1700, 550,600, 500,600, 500,550, 550,600, 550,600, 500,550, 550,1700, 550,600, 500,1650, 550,1750, 500,1650, 550,1750, 500,1700, 500,1750, 500};


int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  pinMode(buttonPin, INPUT);
  
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
    if (buttonState == HIGH) {
    // turn LED on:
    ir.sendRaw(rawData,67,38);
    delay(1);
    digitalWrite(ledPin, HIGH);
    delay(100);
    digitalWrite(ledPin, LOW);
    delay(100);
  }  else {
    // turn LED off:
    digitalWrite(ledPin, HIGH);
    delay(100);
    digitalWrite(ledPin, LOW);
    delay(1000);
  }
}

How did you wire your button? any pull-down? how do you prevent bouncing?

You should code your data this way

unsigned int  rawData[] = {4500,4500, 500,1700, 550,1700, 500,1700, 550,600, 500,600, 500,550, 600,550, 550,600, 500,1650, 550,1750, 500,1700, 500,600, 550,600, 500,600, 500,600, 550,550, 550,600, 500,1700, 550,600, 500,600, 500,550, 550,600, 550,600, 500,550, 550,1700, 550,600, 500,1650, 550,1750, 500,1650, 550,1750, 500,1700, 500,1750, 500};
const unsigned int rawDataCount = sizeof(rawData) / sizeof(rawData[0]);

and send the data using ir.sendRaw(rawData, rawDataCount, 38); to be on the safe side if you miscounted the number of elements

photo of scematic

Attach picture directly here…

Your LED is missing a current limiting resistor
I can’t tell form your drawing which pins of the buttons are connected. they go 2 by 2 usually - have you checked which ones are connected?

Best would be to either use the builtin PULLUP or if you want to use your own resitsor wire all on the same pin to be sure of what’s going on

see for example this tutorial for buttons

You still need to handle bouncing

also where is your IR LED ? is 11 the default for whatever library you use? (some libraries use pin 3)

you need to see the led as an ir led

I added some comments while you were typing - read again #3

also where is your IR LED ? is 11 the default for whatever library you use?

i think so

which library?

did you double check the button? check with this code

const byte buttonPin = 8;
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  Serial.begin(115200);
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    Serial.println("BUTTON");
    delay(15); // poor's man debounce
  }
}

based on your previous code, I just removed all the non necessary stuff. it should display in the console when the button is pressed

What Arduino are you using? AFAIK pin 11 isn't the default output pin for any of them. Have you modified IRremote to use that pin?

Steve

yep i forgot that my library uses pin 3
it works now

oh and i am new so thats why :wink:

unsigned int  rawData[67] = {4500,4500, 500,1700, 550,1700, 500,1700, 550,600, 500,600, 500,550, 600,550, 550,600, 500,1650, 550,1750, 500,1700, 500,600, 550,600, 500,600, 500,600, 550,550, 550,600, 500,1700, 550,600, 500,600, 500,550, 550,600, 550,600, 500,550, 550,1700, 550,600, 500,1650, 550,1750, 500,1650, 550,1750, 500,1700, 500,1750, 500};

I don't understand this.
You could divide those values by 50, and halve the RAM usage.
You could divide the values by 50, and leave them in PROGMEM, and reduce your RAM usage even further.

TolpuddleSartre:
You could divide the values by 50, and leave them in PROGMEM, and reduce your RAM usage even further.

but that would make the array immutable…