help getting ir and buttons to work at same time


i'm new programing , i'm trying work out how leds work remote , buttons 
i can them work till try put them together. buttons don't work independently


code: [select]
#include <irremote.h>

#define re_play 0x800f0416
#define re_enter 0x800f8422
#define recv_pin 11
#define led_pin 13 // choose pin led
const int play_button = 2;
const int enter_button = 3;

byte ledstate;
irrecv irrecv(recv_pin);
decode_results results;
boolean power_state = low;

void setup(){
  serial.begin(9600);
  irrecv.enableirin(); // start receiver
  pinmode(led_pin, output);  // declare led output
  pinmode(play_button, input);
  pinmode(enter_button, input);
  int buttonstate = 0;
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == 0x800f0416) { // sony dvd play
      digitalwrite(led_pin, high);
    }
    else if (results.value == 0x800f8422) { // sony dvd stop
      digitalwrite(led_pin, low
     );
   }
     else if (play_button == high) { // sony dvd play
      digitalwrite(led_pin, high);
    }
    irrecv.resume(); // receive next value
  }

}

hi mark

code: [select]
else if (play_button == high)

if trying read state of pin defined play_button, should ...

code: [select]
else if (digitalread(play_button) == high)

also, statement inside if statement ...

code: [select]
  if (irrecv.decode(&results)) {

so pin checked if decode function returns true, guess happens when ir code received?  need move pin check happens each time round loop().

and want happen if digitalread(play_button) returns low?  there nothing handle @ moment.

regards

ray


Arduino Forum > Using Arduino > Programming Questions > help getting ir and buttons to work at same time


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support