Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 3:ee4b3ea36ec7, committed 2016-04-10
- Comitter:
- alexwynn41
- Date:
- Sun Apr 10 20:06:28 2016 +0000
- Parent:
- 2:577acf73d01f
- Commit message:
- position update
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Apr 10 19:41:30 2016 +0000
+++ b/main.cpp Sun Apr 10 20:06:28 2016 +0000
@@ -75,19 +75,20 @@
spi.frequency(1000000); // SCLK = 1 MHz
Init_MAX7219(); // Initialize the LED controller
MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
+ unsigned char row = 0x03;
unsigned char position[] = {
- 0x03, 0x80
+ 0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00
};
for(int i=1; i<9; i++) // Write first character (8 rows)
SPI_Write2(i,led1[i-1]);
while (1) {
- float x, y, z;
+ float x, y;
x = acc.getAccX();
y = acc.getAccY();
- z = acc.getAccZ();
+
if(x > 0.5){
printf("Left \n");
position[1] = position[1]*2;
@@ -96,23 +97,23 @@
position[1] = position[1]/2;
}else if(y > 0.5){
printf("Up \n");
- position[0] = position[1]-1;
+ position[0] = position[0]-1;
+ row--;
}else if(y < -0.5){
printf("Down \n");
- position[0] = position[1]+2;
+ position[0] = position[0]+1;
+ row++;
}
- /*
- rled = 1.0f - abs(x);
- gled = 1.0f - abs(y);
- bled = 1.0f - abs(z);
- */
- direction(x,y);
- //wait(0.5f);
-
-
+
+
wait(1); // 1 sec delay
SPI_Write2(position[0], position[1]);
+ for(int i=1; i<9; i++){ // Write first character (8 rows)
+ if(i != row){
+ SPI_Write2(i,led1[i-1]);
+ }
+ }
}