This is just a simple test program **to check the hardware**: mbeduino and 4x4x4 LED_cube shield. \\ A class library is available for easy operation. Please find it at...\\ http://mbed.org/users/okano/libraries/LED_Cube444/\\ There are two demo programs for this library available. Please find those at...\\ (1) Very simplified demo sample code : \\ http://mbed.org/users/okano/programs/LED_Cube444_mbeduino-very_simple_demo/\\ (2) More complex (fancy) demo : \\ http://mbed.org/users/okano/programs/LED_Cube444_mbeduino_demo/\\ About the hardware: \\ http://mbed.org/users/okini3939/notebook/mbeduino/ \\ http://www.galileo-7.com/?pid=20015630 \\

Dependencies:   mbed

Committer:
okano
Date:
Thu Oct 14 01:08:36 2010 +0000
Revision:
0:cdfbcd6268db

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:cdfbcd6268db 1 // mbeduino test code (with 4x4x4 LED Cube shield)
okano 0:cdfbcd6268db 2 //
okano 0:cdfbcd6268db 3 // mbeduino = http://mbed.org/users/okini3939/notebook/mbeduino/ (Japanese)
okano 0:cdfbcd6268db 4 // 4x4x4 LED Cube shield = http://www.galileo-7.com/?pid=20015630 (Japanese)
okano 0:cdfbcd6268db 5 //
okano 0:cdfbcd6268db 6 // This is just simple code to check the mbeduino and the 4x4x4 LED Cube shield operation
okano 0:cdfbcd6268db 7 // It turns-on each indivisual LEDs one by one.
okano 0:cdfbcd6268db 8 //
okano 0:cdfbcd6268db 9
okano 0:cdfbcd6268db 10 #include "mbed.h"
okano 0:cdfbcd6268db 11 #include "mbeduino_shield.h"
okano 0:cdfbcd6268db 12
okano 0:cdfbcd6268db 13 #define CUBE_SIZE 4 // n of nodes on one edge
okano 0:cdfbcd6268db 14 #define SR_BIT_LENGTH (CUBE_SIZE * CUBE_SIZE) // n of bits on one layer
okano 0:cdfbcd6268db 15
okano 0:cdfbcd6268db 16 typedef unsigned short U16; // bit length should be same or more than SR_BIT_LENGTH
okano 0:cdfbcd6268db 17
okano 0:cdfbcd6268db 18 #define SR_DATA_OUT ARD_D2 // data line to the shiftregister
okano 0:cdfbcd6268db 19 #define SR_CLCK_OUT ARD_D3 // clock line to the shiftregister
okano 0:cdfbcd6268db 20 #define CATHODE0 ARD_D11 // cathode control line for bottom layer
okano 0:cdfbcd6268db 21 #define CATHODE1 ARD_D10 // cathode control line for 2nd layer from bottom
okano 0:cdfbcd6268db 22 #define CATHODE2 ARD_D9 // cathode control line for 3nd layer from bottom
okano 0:cdfbcd6268db 23 #define CATHODE3 ARD_D8 // cathode control line for top layer
okano 0:cdfbcd6268db 24
okano 0:cdfbcd6268db 25 DigitalOut sr_data(SR_DATA_OUT);
okano 0:cdfbcd6268db 26 DigitalOut sr_clk(SR_CLCK_OUT);
okano 0:cdfbcd6268db 27 BusOut cathode( CATHODE0, CATHODE1, CATHODE2, CATHODE3 );
okano 0:cdfbcd6268db 28
okano 0:cdfbcd6268db 29 //U16 main_buffer[ CUBE_SIZE ] = { 0, 0, 0, 0 };
okano 0:cdfbcd6268db 30
okano 0:cdfbcd6268db 31 void set_serialregister( U16 v );
okano 0:cdfbcd6268db 32
okano 0:cdfbcd6268db 33 int main() {
okano 0:cdfbcd6268db 34 cathode = 0x0;
okano 0:cdfbcd6268db 35
okano 0:cdfbcd6268db 36 while (1) {
okano 0:cdfbcd6268db 37 for ( int c = 0; c < CUBE_SIZE; c++ ) {
okano 0:cdfbcd6268db 38 for ( int i = 0; i < SR_BIT_LENGTH; i++ ) {
okano 0:cdfbcd6268db 39 set_serialregister( 0x0001 << i );
okano 0:cdfbcd6268db 40
okano 0:cdfbcd6268db 41 cathode = 0x1 << c;
okano 0:cdfbcd6268db 42 wait( 0.05 );
okano 0:cdfbcd6268db 43 cathode = 0x0;
okano 0:cdfbcd6268db 44 }
okano 0:cdfbcd6268db 45 }
okano 0:cdfbcd6268db 46 }
okano 0:cdfbcd6268db 47 }
okano 0:cdfbcd6268db 48
okano 0:cdfbcd6268db 49 void set_serialregister( U16 v ) {
okano 0:cdfbcd6268db 50 for ( int i = 0; i < SR_BIT_LENGTH; i++ ) {
okano 0:cdfbcd6268db 51 sr_data = ((v >> i) & 0x1);
okano 0:cdfbcd6268db 52 sr_clk = 0;
okano 0:cdfbcd6268db 53 sr_clk = 1;
okano 0:cdfbcd6268db 54 }
okano 0:cdfbcd6268db 55 }
okano 0:cdfbcd6268db 56
okano 0:cdfbcd6268db 57
okano 0:cdfbcd6268db 58
okano 0:cdfbcd6268db 59
okano 0:cdfbcd6268db 60
okano 0:cdfbcd6268db 61
okano 0:cdfbcd6268db 62
okano 0:cdfbcd6268db 63
okano 0:cdfbcd6268db 64
okano 0:cdfbcd6268db 65
okano 0:cdfbcd6268db 66
okano 0:cdfbcd6268db 67
okano 0:cdfbcd6268db 68
okano 0:cdfbcd6268db 69
okano 0:cdfbcd6268db 70
okano 0:cdfbcd6268db 71
okano 0:cdfbcd6268db 72
okano 0:cdfbcd6268db 73