Hi guys this is my first time posting here, but I'm having trouble with my my code.
I'm trying to send a a row of led light light on when a button is pressed, or when the message is sent.
expected ';' before '}' token
here
//code start
/*******************************************************
* name: Password Lock
* note: you need to add the Keypad folder under test experiment\code\Library to the Arduino libraries folder
* function: when you press one button, you can see the keyvalue print on the serial monitor
* Keypad SunFounder Uno
* X1 8
* X2 9
* X3 10
* X4 11
* Y1 4
* Y2 5
* Y3 6
* Y4 7
*
*********************************************************/
//Email:support@sunfounder.com
//Website:www.sunfounder.com
#include "LedControl.h"
#include "binary.h"
#include <Keypad.h> //use the Keypad libraries
LedControl lc = LedControl(12,13,3,1);
unsigned long delaytime = 1000;
byte a[8]={B11111111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};
byte s[8]={B00000000,B11111111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};
byte d[8]={B00000000,B00000000,B11111111,B00000000,B00000000,B00000000,B00000000,B00000000};
byte f[8]={B00000000,B00000000,B00000000,B11111111,B00000000,B00000000,B00000000,B00000000};
byte g[8]={B00000000,B00000000,B00000000,B00000000,B11111111,B00000000,B00000000,B00000000};
byte h[8]={B00000000,B00000000,B00000000,B00000000,B00000000,B11111111,B00000000,B00000000};
byte j[8]={B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11111111,B00000000};
byte k[8]={B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11111111};
byte l[8]={B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111};
int keyValue = 0;
int incomingByte = 0;
int counter = 0; //Global variable to store our current count
int maximum = 1000; //Global Variable to store the maximum value we will count to
int delayAmount = 500;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] =
{
{ 'a','s','d','f' }
,
{ 'g','h','j','k' }
,
{ 'l','1','0','1' }
,
{ '0','1','0','1' }
};
byte rowPins[ROWS] = { 4, 5, 6, 7}; //connect to the row pinouts of the keypad
byte colPins[COLS] = { 8, 9, 10, 11}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup()
{
Serial.begin(9600);
lc.shutdown(0,false);
lc.setIntensity (0,8);
lc.clearDisplay(0);
}
void drawNotes()
{
if (Serial.print("a"))
lc.setRow(0,0,a[0]);
lc.setRow(0,1,a[1]);
lc.setRow(0,2,a[2]);
lc.setRow(0,3,a[3]);
lc.setRow(0,4,a[4]);
lc.setRow(0,5,a[5]);
lc.setRow(0,6,a[6]);
lc.setRow(0,7,a[7]);
delay(delaytime);
}
{ else if (Serial.print("s"))
lc.setRow(0,0,s[0]);
lc.setRow(0,1,s[1]);
lc.setRow(0,2,s[2]);
lc.setRow(0,3,s[3]);
lc.setRow(0,4,s[4]);
lc.setRow(0,5,s[5]);
lc.setRow(0,6,s[6]);
lc.setRow(0,7,s[7]);
delay(delaytime);
}
{ else if (Serial.print("d"))
lc.setRow(0,0,d[0]);
lc.setRow(0,1,d[1]);
lc.setRow(0,2,d[2]);
lc.setRow(0,3,d[3]);
lc.setRow(0,4,d[4]);
lc.setRow(0,5,d[5]);
lc.setRow(0,6,d[6]);
lc.setRow(0,7,d[7]);
delay(delaytime);
}
{ else if (Serial.print("f"))
lc.setRow(0,0,f[0]);
lc.setRow(0,1,f[1]);
lc.setRow(0,2,f[2]);
lc.setRow(0,3,f[3]);
lc.setRow(0,4,f[4]);
lc.setRow(0,5,f[5]);
lc.setRow(0,6,f[6]);
lc.setRow(0,7,f[7]);
delay(delaytime);
}
{ else if (Serial.print("g"))
lc.setRow(0,0,g[0]);
lc.setRow(0,1,g[1]);
lc.setRow(0,2,g[2]);
lc.setRow(0,3,g[3]);
lc.setRow(0,4,g[4]);
lc.setRow(0,5,g[5]);
lc.setRow(0,6,g[6]);
lc.setRow(0,7,g[7]);
delay(delaytime);
}
{ if (Serial.print("h"))
lc.setRow(0,0,h[0]);
lc.setRow(0,1,h[1]);
lc.setRow(0,2,h[2]);
lc.setRow(0,3,h[3]);
lc.setRow(0,4,h[4]);
lc.setRow(0,5,h[5]);
lc.setRow(0,6,h[6]);
lc.setRow(0,7,h[7]);
delay(delaytime);
}
{ else if (Serial.print("j"))
lc.setRow(0,0,j[0]);
lc.setRow(0,1,j[1]);
lc.setRow(0,2,j[2]);
lc.setRow(0,3,j[3]);
lc.setRow(0,4,j[4]);
lc.setRow(0,5,j[5]);
lc.setRow(0,6,j[6]);
lc.setRow(0,7,j[7]);
delay(delaytime);
}
{ else if (Serial.print("k"))
lc.setRow(0,0,k[0]);
lc.setRow(0,1,k[1]);
lc.setRow(0,2,k[2]);
lc.setRow(0,3,k[3]);
lc.setRow(0,4,k[4]);
lc.setRow(0,5,k[5]);
lc.setRow(0,6,k[6]);
lc.setRow(0,7,k[7]);
delay(delaytime);
}
{ else if (Serial.print("l"))
lc.setRow(0,0,l[0]);
lc.setRow(0,1,l[1]);
lc.setRow(0,2,l[2]);
lc.setRow(0,3,l[3]);
lc.setRow(0,4,l[4]);
lc.setRow(0,5,l[5]);
lc.setRow(0,6,l[6]);
lc.setRow(0,7,l[7]);
delay(delaytime);
}
void readKey()
{
int correct = 0;
char customKey = customKeypad.getKey();//get the key value
if(customKey)
{
Serial.print("");
Serial.println(customKey);
}
//delay(100);
}
void loop()
{
drawNotes();
readKey();
//delay(100);
if (Serial.available() ) {
keyValue = Serial.read();
Serial.println(keyValue);
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
