expected primary expression

In line 31 I'm trying to set the variable key equal to the variable key1. I cant figure out what primary expression it is looking for. Can anyone point me in the right direction?

I'm aware the code following is going to need alot of adjustment also I just haven/'t gotten down there yet


#include <Keypad.h>
#include <Wire.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char key;

char keys[ROWS][COLS] = {

byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6,7,8,9}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


void setup(){
Serial.println("How many milligrams would you like? ");        // tell serial monitor to print message
char key = keypad.getKey();
if (key != 'D'){
 key = int key1;


void loop(){

//Serial.print("Press a key ");        // tell serial monitor to print message
  //char key = keypad.getKey();
    // just print the pressed key
 //  if (key){
  // this checkes if 4 is pressed, then do something. Here  we print the text but you can control something.
  if (key =='D'){
    Serial.println("Enter was pressed");

Also, there is an extra char in there on line 31 also that I forgot to remove prior to posting

What is "key1"?

key is defined as character. Why try to dump an integer into it?

I'm storing that variable for an operation in the loop. Guessing I should have made that a global variable....
Thanks! That little question helped me figure it out!