Programming Assistance

#include <IRremote.h>

const int RECV_PIN = 2;
const int P1_PIN = 3;
const int P2_PIN = 4;
const int P3_PIN = 5;
const int P4_PIN = 6;
const int P5_PIN = 7;
const int P6_PIN = 8;
const int P1RESET_PIN = 9;
const int P2RESET_PIN = 10;
const int P3RESET_PIN = 11;
const int P4RESET_PIN = 12;
const int P5RESET_PIN = 13;
const int P6RESET_PIN = 14;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
  Serial.begin(9600);
irrecv.enableIRIn();
pinMode(P1_PIN, OUTPUT);
pinMode(P2_PIN, OUTPUT);
pinMode(P3_PIN, OUTPUT);
pinMode(P4_PIN, OUTPUT);
pinMode(P5_PIN, OUTPUT);
pinMode(P6_PIN, OUTPUT);
pinMode(P1RESET_PIN, INPUT);
pinMode(P2RESET_PIN, INPUT);
pinMode(P3RESET_PIN, INPUT);
pinMode(P4RESET_PIN, INPUT);
pinMode(P5RESET_PIN, INPUT);
pinMode(P6RESET_PIN, INPUT);
}

void loop() {
 if (digitalRead(P1RESET_PIN == HIGH)){
  digitalWrite(P1_PIN,LOW);
 }
 if (digitalRead(P2RESET_PIN == HIGH)){
  digitalWrite(P2_PIN,LOW);
 }
  if (digitalRead(P3RESET_PIN == HIGH)){
  digitalWrite(P3_PIN,LOW);
 }
  if (digitalRead(P4RESET_PIN == HIGH)){
  digitalWrite(P4_PIN,LOW);
 }
  if (digitalRead(P5RESET_PIN == HIGH)){
  digitalWrite(P5_PIN,LOW);
 }
  if (digitalRead(P6RESET_PIN == HIGH)){
  digitalWrite(P6_PIN,LOW);
 }
 if (irrecv.decode(&results)){
  switch(results.value, HEX){
    case 0x20DF8877:
    digitalWrite(P1_PIN,HIGH);
    Serial.println("player 1");
    break;
 
    case 0x20DF48B7:
    digitalWrite(P2_PIN,HIGH);
    break;
  
    case 0x20DFC837:
    digitalWrite(P3_PIN,HIGH);
    break;
    
    case 0x20DF28D7:
    digitalWrite(P4_PIN,HIGH);
    break;
    
    case 0x20DFA857:
    digitalWrite(P5_PIN,HIGH);
    break;
    
    case 0x20DF6897:
    digitalWrite(P6_PIN,HIGH);
    break;
  }
 irrecv.resume();
 }
}

Error Below

C:\Users\p-jcooper\Documents\Arduino\Shooting_Gallery_Main_Test\Target_Script\Target_Script.ino: In function 'void loop()':
C:\Users\p-jcooper\Documents\Arduino\Shooting_Gallery_Main_Test\Target_Script\Target_Script.ino:56:5: warning: overflow in implicit constant conversion [-Woverflow]
     case 0x20DF8877:
     ^~~~
C:\Users\p-jcooper\Documents\Arduino\Shooting_Gallery_Main_Test\Target_Script\Target_Script.ino:61:5: warning: overflow in implicit constant conversion [-Woverflow]
     case 0x20DF48B7:
     ^~~~
C:\Users\p-jcooper\Documents\Arduino\Shooting_Gallery_Main_Test\Target_Script\Target_Script.ino:65:5: warning: overflow in implicit constant conversion [-Woverflow]
     case 0x20DFC837:
     ^~~~
C:\Users\p-jcooper\Documents\Arduino\Shooting_Gallery_Main_Test\Target_Script\Target_Script.ino:69:5: warning: overflow in implicit constant conversion [-Woverflow]
     case 0x20DF28D7:
     ^~~~
C:\Users\p-jcooper\Documents\Arduino\Shooting_Gallery_Main_Test\Target_Script\Target_Script.ino:73:5: warning: overflow in implicit constant conversion [-Woverflow]
     case 0x20DFA857:
     ^~~~
C:\Users\p-jcooper\Documents\Arduino\Shooting_Gallery_Main_Test\Target_Script\Target_Script.ino:77:5: warning: overflow in implicit constant conversion [-Woverflow]
     case 0x20DF6897:
     ^~~~

Any information on how to fix this?

switch(results.value, HEX)

The HEX parameter cannot be used here nor is it needed

  if (digitalRead(P6RESET_PIN == HIGH)){

Check the syntax of digitalRead()

#include <IRremote.h>
const unsigned long P1 = 0x20DF8877;
const unsigned long P2 = 0x20DF48B7;
const unsigned long P3 = 0x20DFC837;
const unsigned long P4 = 0x20DF28D7;
const unsigned long P5 = 0x20DFA857;
const unsigned long P6 = 0x20DF6897;
const int RECV_PIN = 2;
const int P1_PIN = 3;
const int P2_PIN = 4;
const int P3_PIN = 5;
const int P4_PIN = 6;
const int P5_PIN = 7;
const int P6_PIN = 8;
const int P1RESET_PIN = 9;
const int P2RESET_PIN = 10;
const int P3RESET_PIN = 11;
const int P4RESET_PIN = 12;
const int P5RESET_PIN = 13;
const int P6RESET_PIN = 14;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
  Serial.begin(9600);
irrecv.enableIRIn();
pinMode(P1_PIN, OUTPUT);
pinMode(P2_PIN, OUTPUT);
pinMode(P3_PIN, OUTPUT);
pinMode(P4_PIN, OUTPUT);
pinMode(P5_PIN, OUTPUT);
pinMode(P6_PIN, OUTPUT);
pinMode(P1RESET_PIN, INPUT);
pinMode(P2RESET_PIN, INPUT);
pinMode(P3RESET_PIN, INPUT);
pinMode(P4RESET_PIN, INPUT);
pinMode(P5RESET_PIN, INPUT);
pinMode(P6RESET_PIN, INPUT);
}

void loop() {
 if (digitalRead(P1RESET_PIN == HIGH)){
  digitalWrite(P1_PIN,LOW);
 }
 if (digitalRead(P2RESET_PIN == HIGH)){
  digitalWrite(P2_PIN,LOW);
 }
  if (digitalRead(P3RESET_PIN == HIGH)){
  digitalWrite(P3_PIN,LOW);
 }
  if (digitalRead(P4RESET_PIN == HIGH)){
  digitalWrite(P4_PIN,LOW);
 }
  if (digitalRead(P5RESET_PIN == HIGH)){
  digitalWrite(P5_PIN,LOW);
 }
  if (digitalRead(P6RESET_PIN == HIGH)){
  digitalWrite(P6_PIN,LOW);
 }
 if (irrecv.decode(&results)){
  switch(results.value){
    case P1:
    digitalWrite(P1_PIN,HIGH);
    Serial.println("player 1");
    break;
 
    case P2:
    digitalWrite(P2_PIN,HIGH);
    break;
  
    case P3:
    digitalWrite(P3_PIN,HIGH);
    break;
    
    case P4:
    digitalWrite(P4_PIN,HIGH);
    break;
    
    case P5:
    digitalWrite(P5_PIN,HIGH);
    break;
    
    case P6:
    digitalWrite(P6_PIN,HIGH);
    break;
  }
 irrecv.resume();
 }
}

I have done as instructed didn’t see the issue with bellow could you explain more of what you are seeing?

  if (digitalRead(P6RESET_PIN == HIGH)){

Check the syntax of digitalRead()

You are passing the results of the condition:

  P6RESETPIN == HIGH

As the parameter to the call to digitalRead()., what you really want to do is compare the value returned by:

  digitalRead(P6RESETPIN)

To LOW, take note of where your opening ( and closing ) parenthesis are, what you need is:

  if (digitalRead(P6RESETPIN) == LOW)

syntax of digitalRead() : digitalRead() - Arduino Reference.

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