@peekay123 Okay, I've edited the code following your corrections, and there are just 4 error messages left to correct! Here is the most recent code:
// This #include statement was automatically added by the Particle IDE.
#include <adafruit-led-backpack.h>
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
#include <stdlib.h>
#include <application.h>
char auth[] = 558bc6ae35b54915b4591cd0b994c27a;
Adafruit_8x8matrix matrix1;
Adafruit_8x8matrix matrix2;
void setupMatrix ( void *mat )
{
Adafruit_8x8matrix *m = (Adafruit_8x8matrix*) mat;
m->clear();
m->writeDisplay();
m->setTextSize(1);
m->setTextWrap(false);
m->setTextColor(LED_ON);
m->setRotation(0);
m->setCursor(0, 0);
}
struct cardsandCount
{
int cards [25];
int count;
int sum;
};
struct cardsandCount playerStats = { {0}, 0, 0};
struct cardsandCount compStats = { {0}, 0, 0};
struct cardsandCount *compFlag;
struct cardsandCount *playerFlag;
WidgetLCD lcd(V1),(V2);
enum { STAND,HIT };
int pinDataV1 = 0, pinDataV2 = 0;
struct cardsandCount *initialdealPlayer ( struct cardsandCount *theStruct );
struct cardsandCount *initialdealComp (struct cardsandCount *theStruct );
void displayonLCD ( struct cardsandCount *theStruct ); //declaration of functions, function definitions at the bottom
void displaySum ( struct cardsandCount *theStruct );
struct cardsandCount *random_generator ( struct cardsandCount *theStruct );
struct cardsandCount *sumofCards ( struct cardsandCount *theStruct );
void decideWinner ( struct cardsandCount *playerStruct, struct cardsandCount *compStruct );
void setup()
{
uint32_t seed = millis();
srand(seed);
Serial.begin(9600);
delay(5000); // Allow board to settle
lcd.clear();
Blynk.begin(auth);
// set the I2C address of each matrix
matrix1.begin(0x70);
matrix2.begin(0x71);
// initialize each matrix
setupMatrix(&matrix1);
setupMatrix(&matrix2);
playerFlag = initialdealPlayer ( &playerStats );
playerFlag = sumofCards ( playerFlag );
displaySum (playerFlag);
displayonLCD (playerFlag);
compFlag = initialdealComp (&compStats);
compFlag = sumofCards ( compFlag );
while ( compFlag->sum < 17 )
{
compFlag = random_generator ( compFlag );
compFlag = sumofCards (compFlag);
}
}
void loop ()
{
Blynk.run();
}
struct cardsandCount *initialdealPlayer ( struct cardsandCount *theStruct )
{
struct cardsandCount *structPointer = theStruct;
for ( int i = 0; i < 2; i++ )
{
structPointer->cards [i] = rand () % 10 + 1;
}
return structPointer;
}
struct cardsandCount *initialdealComp (struct cardsandCount *theStruct )
{
struct cardsandCount *structPointer = theStruct;
for ( int i = 0; i < 2; i++ )
{
compStats.cards [i] = rand () % 10 + 1;
}
return structPointer;
}
void displayonLCD ( struct cardsandCount *theStruct )
{
struct cardsandCount *structPointer = theStruct;
for ( int i = 0; i < structPointer->count; i++ )
{
lcd.print(i, 0, structPointer->cards [i]);
}
}
void displaySum ( struct cardsandCount *theStruct )
{
struct cardsandCount *structPointer;
char ones = structPointer->sum % 10;
char tens = structPointer->sum / 10;
// write the ones digit to matrix1
matrix1.clear();
matrix1.setCursor(0, 0);
matrix1.write(tens + '0'); // the ASCII value of tens is ‘0’+tens
matrix1.writeDisplay();
// write the tens digit to matrix2
matrix2.clear();
matrix2.setCursor(0, 0);
matrix2.write(ones + '0');
matrix2.writeDisplay();
}
struct cardsandCount *random_generator ( struct cardsandCount *theStruct )
{
struct cardsandCount *structPointer = theStruct;
int i = 0;
while( structPointer->cards[i] != 0 )
{
i++;
}
structPointer->cards[i] = rand () % 10 + 1;
structPointer->count++;
return structPointer;
}
struct cardsandCount *sumofCards ( struct cardsandCount *theStruct )
{
struct cardsandCount *structPointer = theStruct ;
for ( int i = 0; i < structPointer->count; i++ )
{
structPointer->sum += structPointer->cards [i];
}
return structPointer;
}
BLYNK_WRITE(V1)
{
pinDataV1 = param.asInt ();
}
BLYNK_WRITE(V2)
{
pinDataV2 = param.asInt ();
if ( V1 == 1 && V2 == 0)
{
playerFlag = random_generator (playerFlag);
playerFlag = sumofCards ( playerFlag );
displaySum (playerFlag);
displayonLCD (playerFlag);
}
else if (V1 == 0 && V2 == 1)
{
playerFlag = sumofCards (playerFlag);
decideWinner ( playerFlag, compFlag );
}
}
void decideWinner ( struct cardsandCount *playerStruct, struct cardsandCount *compStruct)
{
struct cardsandCount *playerPointer, *compPointer;
if ( playerPointer->sum > compPointer->sum )
{
lcd.print(0,0,"Player wins!");
}
else if ( playerPointer->sum < compPointer->sum )
{
lcd.print (0,0,"Computer wins!");
}
else if (playerPointer->sum ==compPointer->sum )
{
lcd.print("It's a draw");
}
}
I dropped the #include <time.h>
since the compiler could not recognize it. Instead I followed the example provided in this link:
The four error messages are:
/workspace//src/blackjack.cpp:8:15: error: unable to find numeric literal operator 'operator"" bc6ae35b54915b4591cd0b994c27a'
void setupMatrix ( void *mat );
^
/workspace/lib/blynk/src/Blynk/BlynkHandlers.h:21:13: error: expected unqualified-id before numeric constant
#define V2 2
^
/workspace/lib/blynk/src/Blynk/BlynkHandlers.h:21:13: error: expected ')' before numeric constant
#define V2 2
^
/workspace//src/blackjack.cpp:216:32: error: no matching function for call to 'WidgetLCD::print(const char [12])'
}
^
I don't know how to resolve all the above errors. How do I declare two push buttons on Blynk? And also, I'm not sure how to print the strings in decideWinner function to the LCD terminal of Blynk.
Thanks!