Help with particle photon keypad

Particle keeps giving us the “expected identifier before ‘=’ token”, “expected declaration before ‘}’ token”, “expected declaration before ‘}’ token”, and “expected unqualified-id before ‘=’ token” errors on the byte colPins line. please help! <3

// This #include statement was automatically added by the Particle IDE.
#include <Keypad.h>

const byte ROWS = 3;    //3 rows
const byte COLS = 3;    //3 columns
//define symbols on buttons
char keys [ROWS] [COLS] = 
{
    {'1' , '2' , '3'},
    {'4' , '5' , '6'},
    {'7' , '8' , '9'},
};

byte rowPins[ROWS] = {8, 7, 6};   //connection from row
byte colPins[COLS] = {4, 3, 2};   //connection from column 

//initialize an instance of class NewKeypad
Keypad keypad = Keypad (makeKeymap(keys) , rowPins , colPins , ROWS , COLS);

void setup ()
{
    Serial.begin ( 9600 );
}

void loop ()
{
    char key = keypad.getKey ();
    if (key)
    {
        Serial.println (key);
    }
}

Take a close look at this :wink:
(doesn't seem to be quite the issue, but there's something not right regardless)

1 Like

we exactly copied the code you provided and verified it, it was right once then we verified it again and it showed the same errors we originally had.

// This #include statement was automatically added by the Particle IDE.
#include <Keypad_Particle.h>

const byte ROWS = 4;    //3 rows
const byte COLS = 3;    //3 columns
//define symbols on buttons
char keys [ROWS] [COLS] = 
{
    {'1' , '2' , '3'},
    {'4' , '5' , '6'},
    {'7' , '8' , '9'},
    {'*' , '0' , '#'}
};

byte rowPins[ROWS] = {D3, D2, D1, D0};   //connection from row
byte colPins[COLS] = {D6, D5, D4};   //connection from column 

//initialize an instance of class NewKeypad
Keypad keypad = Keypad (makeKeymap(keys) , rowPins , colPins , ROWS , COLS);

void setup ()
{
    Serial.begin ( 9600 );
}

void loop ()
{
    char key = keypad.getKey ();
    if (key)
    {
        Serial.println (key);
    }
}

Not exactly sure why it’s spitting those errors, but if it’s all the same to you, there seems to be an alternative version of that library that doesn’t shoot those errors:
https://go.particle.io/shared_apps/5adf6c7ecdc59c2b5d00069a

we exactly copied the code you provided and verified it, it was right once then we verified it again and it showed the same errors we originally had.

#include <Keypad_Particle.h>

const byte ROWS = 4; //3 rows
const byte COLS = 3; //3 columns
//define symbols on buttons
char keys [ROWS] [COLS] =
{
{‘1’ , ‘2’ , ‘3’},
{‘4’ , ‘5’ , ‘6’},
{‘7’ , ‘8’ , ‘9’},
{’*’ , ‘0’ , ‘#’}
};

byte rowPins[ROWS] = {D3, D2, D1, D0}; //connection from row
byte colPins[COLS] = {D6, D5, D4}; //connection from column

//initialize an instance of class NewKeypad
Keypad keypad = Keypad (makeKeymap(keys) , rowPins , colPins , ROWS , COLS);

void setup ()
{
Serial.begin ( 9600 );
}

void loop ()
{
char key = keypad.getKey ();
if (key)
{
Serial.println (key);
}
}

Could you post the Share link from the Web IDE? That way there won’t be any copy&paste errors.

In the last code you posted there there are definetly wrong characters

{‘1’ , ‘2’ , ‘3’},

where it should be

{'1' , '2' , '3'},

But also what system version are you targeting with your build (builds fine for me with 0.6.3+) and what exactly does the error message say.
Can you copy paste the exact message with its context (by hitting SHOW RAW)?

1 Like