Help For Buttons

Hi There! I Have a project to create 2 button IR Remote! But The Problem Is:

  • If Voldown button pressed all of codes executed so resulting in a 2 IR Codes Send to The Transmitter With One Button

So How To solve it? Each Button For Each Code?

The Code Is:

#include <IRremote.h>

IRsend irsend;

int voldown = 2;
int volup = 7;
int lampu = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(voldown, INPUT);
  pinMode(volup, INPUT);
  pinMode(lampu, OUTPUT);
  digitalWrite(voldown, HIGH); //activate arduino internal pull up
  Serial.begin(9600);
}
void loop() {
  // put your main code here, to run repeatedly:
  if (digitalRead(voldown)==LOW){
    Serial.println("Button VOL - is pressed");
    digitalWrite(13, HIGH);
    irsend.sendNEC(0x1FE8A75, 32);
  if (digitalRead(volup)==LOW){
    Serial.println("Button VOL + is pressed");
    digitalWrite(13, HIGH);
    irsend.sendNEC(0x1FE0AF5, 32);
  } else {
    // If Button Depressed, to run repeatedly:
    digitalWrite(lampu, LOW);
  }
  // put your main code here, to run repeatedly:
  delay(200);
  }
}

UPDATE: OK OK Solved By Myself! :slight_smile: I Forgot To Add volup’s Internal Pull Up XD