dice

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#define btnSELECT 4
int button;
int lcd_key;
int randNumber;
void setup() {
lcd.begin(16, 2);
lcd.setCursor (5, 0);
lcd.println ("catan" );
button = analogRead(A0);
}
void loop() {
randNumber = random(1, 7);
Serial.println(randNumber);
switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnSELECT:
{
lcd.print("rolling dice");
break;
}
}
}
I am trying to make a dice to play catan with, can someone help me, plz
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#define btnSELECT 4
int button;
int lcd_key;
int randNumber;
void setup() {
lcd.begin(16, 2);
lcd.setCursor (5, 0);
lcd.println ("catan" );
button = analogRead(A0);
}
void loop() {
randNumber = random(1, 7);
Serial.println(randNumber);
switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnSELECT:
{
lcd.print("rolling dice");
break;
}
}
}
I am trying to make a dice to play catan with, can someone help me, plz
2018-04-19 23:15:25 when i upload the code, i get
Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"
In file included from C:\Users\taran\Desktop\arduino\demo_simple\demo_simple.ino:3:0:
C:\Users\taran\Desktop\arduino\demo_simple\demo_simple.ino: In function 'void loop()':
C:\Users\taran\Documents\Arduino\libraries\DFR_LCD_Keypad-master/DFR_LCD_Keypad.h:35:35: error: expected '(' before numeric constant
#define DFR_LCD_KEYPAD_KEY_SELECT 4
^
C:\Users\taran\Documents\Arduino\libraries\DFR_LCD_Keypad-master/DFR_LCD_Keypad.h:55:20: note: in expansion of macro 'DFR_LCD_KEYPAD_KEY_SELECT'
#define KEY_SELECT DFR_LCD_KEYPAD_KEY_SELECT
^
C:\Users\taran\Desktop\arduino\demo_simple\demo_simple.ino:31:10: note: in expansion of macro 'KEY_SELECT'
if KEY_SELECT:{
^
demo_simple:50: error: expected '}' at end of input
}
and the code is
#include <LiquidCrystal.h>
#include <DFR_LCD_Keypad.h>
// this is factory config shield initialisation
LiquidCrystal lcd(8,9,4,5,6,7);
// below is for shield which has been modified (author's shield)
//LiquidCrystal lcd(8,3,4,5,6,7);
// initialise the keypad
DFR_LCD_Keypad keypad(A0, &lcd);
#define btnSELECT 4;
int abc_key_in;
int read_LCD_buttons(){
abc_key_in = analogRead(0);
if (abc_key_in <850) return btnSELECT;
}
int diceOne;
int diceTwo;
void setup(){
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Press to dice");
}
void loop(){
if KEY_SELECT:{
diceOne = random(1, 7);
diceTwo = random(1, 7);
if (diceOne + diceTwo == 7) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("7");
lcd.setCursor(3, 1);
lcd.print("The pirate");
if (diceOne + diceTwo == 5, 4, 3, 2, 6 ) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("5,4,3,2,6");
}
}
}
taranclan21
Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"
In file included from C:\Users\taran\Desktop\arduino\demo_simple\demo_simple.ino:3:0:
C:\Users\taran\Desktop\arduino\demo_simple\demo_simple.ino: In function 'void loop()':
C:\Users\taran\Documents\Arduino\libraries\DFR_LCD_Keypad-master/DFR_LCD_Keypad.h:35:35: error: expected '(' before numeric constant
#define DFR_LCD_KEYPAD_KEY_SELECT 4
^
C:\Users\taran\Documents\Arduino\libraries\DFR_LCD_Keypad-master/DFR_LCD_Keypad.h:55:20: note: in expansion of macro 'DFR_LCD_KEYPAD_KEY_SELECT'
#define KEY_SELECT DFR_LCD_KEYPAD_KEY_SELECT
^
C:\Users\taran\Desktop\arduino\demo_simple\demo_simple.ino:31:10: note: in expansion of macro 'KEY_SELECT'
if KEY_SELECT:{
^
demo_simple:50: error: expected '}' at end of input
}
and the code is
#include <LiquidCrystal.h>
#include <DFR_LCD_Keypad.h>
// this is factory config shield initialisation
LiquidCrystal lcd(8,9,4,5,6,7);
// below is for shield which has been modified (author's shield)
//LiquidCrystal lcd(8,3,4,5,6,7);
// initialise the keypad
DFR_LCD_Keypad keypad(A0, &lcd);
#define btnSELECT 4;
int abc_key_in;
int read_LCD_buttons(){
abc_key_in = analogRead(0);
if (abc_key_in <850) return btnSELECT;
}
int diceOne;
int diceTwo;
void setup(){
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Press to dice");
}
void loop(){
if KEY_SELECT:{
diceOne = random(1, 7);
diceTwo = random(1, 7);
if (diceOne + diceTwo == 7) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("7");
lcd.setCursor(3, 1);
lcd.print("The pirate");
if (diceOne + diceTwo == 5, 4, 3, 2, 6 ) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("5,4,3,2,6");
}
}
}

2018-04-19 11:57:13 can you see what the problem is, I cant.
C:\Users\taran\Documents\Arduino\screen_test\screen_test.ino: In function 'void loop()':
screen_test:33: error: expected primary-expression before ')' token
)
^
screen_test:41: error: expected primary-expression before ')' token
)
^
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int count;
int setCursor;
int setColumn;
int countDelay;
int diceOne;
int diceTwo;
int KEY_SELECT;
void setup() {
lcd.begin(16, 2);
lcd.setCursor(1, 0);
lcd.print("Roll the dice!");
}
void buildUp() {
lcd.clear();
for (count = 0; count <= 16; count++) {
lcd.setCursor(setColumn, 0);
lcd.print(random(1, 7));
lcd.setCursor(setColumn, 1);
lcd.print(random(1, 7));
delay(countDelay);
countDelay -= 13;
setColumn += 1;
}
}
void loop() {
while(analogRead(KEY_SELECT) == LOW) (
)
if(analogRead(KEY_SELECT) == HIGH) (
diceOne = random(1, 7);
diceTwo = random(1, 7);
)
buildUp();
lcd.clear();
lcd.setCursor(7, 0);
lcd.print(diceOne);
lcd.setCursor(7, 1);
lcd.print(diceTwo);
if (diceOne + diceTwo == 7) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("7");
lcd.setCursor(3, 1);
lcd.print("The pirate");
if (diceOne + diceTwo == 5, 4, 3, 2, 6 ) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("5,4,3,2,6");
}
}
)
taranclan21
C:\Users\taran\Documents\Arduino\screen_test\screen_test.ino: In function 'void loop()':
screen_test:33: error: expected primary-expression before ')' token
)
^
screen_test:41: error: expected primary-expression before ')' token
)
^
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int count;
int setCursor;
int setColumn;
int countDelay;
int diceOne;
int diceTwo;
int KEY_SELECT;
void setup() {
lcd.begin(16, 2);
lcd.setCursor(1, 0);
lcd.print("Roll the dice!");
}
void buildUp() {
lcd.clear();
for (count = 0; count <= 16; count++) {
lcd.setCursor(setColumn, 0);
lcd.print(random(1, 7));
lcd.setCursor(setColumn, 1);
lcd.print(random(1, 7));
delay(countDelay);
countDelay -= 13;
setColumn += 1;
}
}
void loop() {
while(analogRead(KEY_SELECT) == LOW) (
)
if(analogRead(KEY_SELECT) == HIGH) (
diceOne = random(1, 7);
diceTwo = random(1, 7);
)
buildUp();
lcd.clear();
lcd.setCursor(7, 0);
lcd.print(diceOne);
lcd.setCursor(7, 1);
lcd.print(diceTwo);
if (diceOne + diceTwo == 7) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("7");
lcd.setCursor(3, 1);
lcd.print("The pirate");
if (diceOne + diceTwo == 5, 4, 3, 2, 6 ) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("5,4,3,2,6");
}
}
)

2018-04-10 17:45:22 Have you add the library and could you inform which product were you using? Have you find where to download DFRKeypad.h?
robert.chen

2018-04-09 22:53:01 I keep getting and, do I set pinMode to ( btnSELECT, INPUT); if I want to press select to roll generate random numbers?
Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\taran\Documents\Arduino\dice_for_catan\dice_for_catan.ino:3:23: fatal error: DFRKeypad.h: No such file or directory
#include <DFRKeypad.h>
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#include <DFRKeypad.h>
int localKey = 1;
int count = 0;
long diceOne;
long diceTwo;
int countDelay = 220;
int setColumn = 0;
void setup() {
lcd.begin(16, 2);
pinMode( btnSELECT, INPUT);
lcd.setCursor(8, 0);
lcd.print("Roll the dice!");
}
void buildUp() {
lcd.clear();
for (count = 0; count <= 16; count++) {
lcd.setCursor(setColumn, 0);
lcd.print(random(1, 7));
lcd.setCursor(setColumn, 1);
lcd.print(random(1, 7));
delay(countDelay);
countDelay -= 13;
setColumn += 1;
}
}
void loop() {
if (localKey != SAMPLE_WAIT)
{
lcd.clear();
lcd.setCursor(8, 0);
lcd.print("rolling dice");
}
randomSeed(analogRead(0));
diceOne = random(1, 7);
diceTwo = random(1, 7);
buildUp();
lcd.clear();
lcd.setCursor(7, 0);
lcd.print(diceOne);
lcd.setCursor(7, 1);
lcd.print(diceTwo);
if (diceOne + diceTwo == 7) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("7");
lcd.setCursor(3, 1);
lcd.print("The pirate");
}
if (diceOne + diceTwo == 5,4,3,2,6 ){
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("5,4,3,2,6");
}
}
taranclan21
Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\taran\Documents\Arduino\dice_for_catan\dice_for_catan.ino:3:23: fatal error: DFRKeypad.h: No such file or directory
#include <DFRKeypad.h>
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#include <DFRKeypad.h>
int localKey = 1;
int count = 0;
long diceOne;
long diceTwo;
int countDelay = 220;
int setColumn = 0;
void setup() {
lcd.begin(16, 2);
pinMode( btnSELECT, INPUT);
lcd.setCursor(8, 0);
lcd.print("Roll the dice!");
}
void buildUp() {
lcd.clear();
for (count = 0; count <= 16; count++) {
lcd.setCursor(setColumn, 0);
lcd.print(random(1, 7));
lcd.setCursor(setColumn, 1);
lcd.print(random(1, 7));
delay(countDelay);
countDelay -= 13;
setColumn += 1;
}
}
void loop() {
if (localKey != SAMPLE_WAIT)
{
lcd.clear();
lcd.setCursor(8, 0);
lcd.print("rolling dice");
}
randomSeed(analogRead(0));
diceOne = random(1, 7);
diceTwo = random(1, 7);
buildUp();
lcd.clear();
lcd.setCursor(7, 0);
lcd.print(diceOne);
lcd.setCursor(7, 1);
lcd.print(diceTwo);
if (diceOne + diceTwo == 7) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("7");
lcd.setCursor(3, 1);
lcd.print("The pirate");
}
if (diceOne + diceTwo == 5,4,3,2,6 ){
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("5,4,3,2,6");
}
}
