to verify the position of the LEDs
This is an attempt to address all the 25 LEDs. This has been done but only on rows. I need to arrange the column calls in some form of array which can be indexed.
Diff: main.cpp
- Revision:
- 8:7a49220aaa22
- Parent:
- 7:0f62c513f003
- Child:
- 9:bf2d151b3b6e
--- a/main.cpp Tue Oct 22 15:00:47 2019 +1100 +++ b/main.cpp Tue Oct 22 11:25:52 2019 +0000 @@ -6,7 +6,7 @@ * a screen, there is a display driver in the micro:bit 'DAL', */ // 21 Oct 2019 -int seq[5] = {P0_15,P0_13,P0_14,P0_11}; +/*int seq[5] = {P0_15,P0_13,P0_14,P0_11}; void myLedBlink(int led) { led = 1; @@ -14,6 +14,7 @@ led = 0; wait(0.2); } +*/ // https://www.iot-programmer.com/index.php/books/27-micro-bit-iot-in-c/chapters-micro-bit-iot-in-c/54-micro-bit-iot-in-c-the-led-display DigitalOut col1(P0_4,0); DigitalOut col2(P0_5,0); @@ -29,35 +30,53 @@ DigitalOut row1(P0_13); // something DigitalOut row2(P0_14); // guessing the layout of the LEDs ATM DigitalOut row3(P0_15); // something +typedef int (*IntFunctionWithOneParameter) (int a); + +int function(int a) +{ + return a; +} +int functionTimesTwo(int a) +{ + return a*2; +} +int functionDivideByTwo(int a) +{ + return a/2; +} + int main() { + IntFunctionWithOneParameter functions[] = { + function, + functionTimesTwo, + functionDivideByTwo, +// row1 + // row1(P0_13) row1(P0_13) + }; + + for(int i = 0; i < 3; ++i) { +// cout << functions[i](8) << endl; + functions[i](8); + } while(1) { // for (int cv = 0; cv < 4 ; cv++) { // myLedBlink(seq[cv]); // } row3 = 1; - wait(0.2); - row3 = 0; - wait(0.2); // ** row2 = 1; - wait(0.2); - row2 = 0; - wait(0.2); // ** row1 = 1; - wait(0.2); - row1 = 0; - wait(0.2); // ** //}