Whack a Mole game! Features: - LCD graphics display - Touch pad input - Speaker effects through a class D audio amplifier\ - A high score page maintained by the SD card file system - Analog noise used to seed random numbers

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed

Fork of MPR121_Demo by jim hamblen

Revision:
5:070755be0a77
Parent:
4:4cb02cde783c
Child:
6:ca03b9c94c88
--- a/main.cpp	Mon Mar 14 04:44:41 2016 +0000
+++ b/main.cpp	Mon Mar 14 05:36:09 2016 +0000
@@ -25,7 +25,8 @@
 #include <list>
 #include "uLCD_4DGL.h"
 #include <mpr121.h>
-
+#include "SDFileSystem.h"
+#include "SongPlayer.h"
 uLCD_4DGL lcd(p9, p10, p30); // tx, rx, reset
 
 DigitalOut led1(LED1);
@@ -38,10 +39,11 @@
 InterruptIn interrupt(p26);
 // Setup the Serial to the PC for debugging
 Serial pc(USBTX, USBRX);
-
+SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
 // Setup the i2c bus on pins 28 and 27
 I2C i2c(p28, p27);
-
+float note[1]= {1568.0};
+float duration[1]= {0.1};
 int pos1;
 int pos2;
 int pos3;
@@ -55,6 +57,7 @@
 int hole4 = 0x200;
 int hole5 = 0x20;
 int hole6 = 0x2;
+char str [80];
 // Setup the Mpr121:
 // constructor(i2c object, i2c address of the mpr121)
 Mpr121 mpr121(&i2c, Mpr121::ADD_VSS);
@@ -506,6 +509,31 @@
         //lcd.text_string("What does...", 1, 1, FONT_7X8, GREEN);
         //lcd.text_string("What does...", 1, 8, FONT_7X8, BLUE);
         lcd.printf("you scored %D",score);
+        /*FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
+        if(fp == NULL) {
+        pc.printf("Could not open file for write\n");
+        }
+        fprintf(fp, "Hello fun SD Card World!");
+        fclose(fp);*/
+            static const char SampleString[] = "Hello World\n";
+    mkdir("/sd/write_test", 0777);
+    FILE *fp = fopen("/sd/write_test/out.txt", "w");
+    //FILE* fp = fopen("/local/out.txt", "w");
+    if(fp == NULL) 
+    {
+        error("Could not open file for write\n");
+    }
+    fprintf(fp, "Hello from SD Card World!");    
+    fclose(fp); 
+    FILE *fp1 = fopen("/sd/mydir/sdtest.txt", "r"); 
+    if(fp1 == NULL) 
+    { 
+    error("Could not open file for read\n"); 
+    }
+    pc.printf("Opened file for read\n\r");
+    fscanf (fp1, "%s", str);
+    pc.printf ("I have read:   %s \n",str);
+    fclose(fp1);
     }