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.
main.cpp@6:83feebd43ec8, 2019-10-22 (annotated)
- Committer:
- matrixmike
- Date:
- Tue Oct 22 03:50:13 2019 +0000
- Revision:
- 6:83feebd43ec8
- Parent:
- 5:7881d6e0732f
- Child:
- 7:0f62c513f003
all columns and all rows
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
matrixmike | 0:699a0e5dc3ab | 1 | #include "mbed.h" |
matrixmike | 0:699a0e5dc3ab | 2 | /* |
matrixmike | 0:699a0e5dc3ab | 3 | * All the LEDs on the micro:bit are part of the LED Matrix, |
matrixmike | 0:699a0e5dc3ab | 4 | * In order to get simple blinking behaviour, we set column 0 |
matrixmike | 0:699a0e5dc3ab | 5 | * to be permanently at ground. If you want to use the LEDs as |
matrixmike | 0:699a0e5dc3ab | 6 | * a screen, there is a display driver in the micro:bit 'DAL', |
matrixmike | 0:699a0e5dc3ab | 7 | */ |
matrixmike | 0:699a0e5dc3ab | 8 | // 21 Oct 2019 |
matrixmike | 2:71c7441b477a | 9 | int seq[5] = {P0_15,P0_13,P0_14,P0_11}; |
matrixmike | 2:71c7441b477a | 10 | void myLedBlink(int led) |
matrixmike | 2:71c7441b477a | 11 | { |
matrixmike | 2:71c7441b477a | 12 | led = 1; |
matrixmike | 2:71c7441b477a | 13 | wait(0.2); |
matrixmike | 2:71c7441b477a | 14 | led = 0; |
matrixmike | 2:71c7441b477a | 15 | wait(0.2); |
matrixmike | 2:71c7441b477a | 16 | } |
matrixmike | 3:c6d14249d784 | 17 | // 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 |
matrixmike | 4:0dc3e04090ab | 18 | DigitalOut col1(P0_4,0); |
matrixmike | 4:0dc3e04090ab | 19 | DigitalOut col2(P0_5,0); |
matrixmike | 3:c6d14249d784 | 20 | DigitalOut col3(P0_6,0); |
matrixmike | 4:0dc3e04090ab | 21 | DigitalOut col4(P0_7,0); |
matrixmike | 4:0dc3e04090ab | 22 | DigitalOut col5(P0_8,0); |
matrixmike | 4:0dc3e04090ab | 23 | DigitalOut col6(P0_9,0); |
matrixmike | 4:0dc3e04090ab | 24 | DigitalOut col7(P0_10,0); |
matrixmike | 4:0dc3e04090ab | 25 | DigitalOut col8(P0_11,0); |
matrixmike | 4:0dc3e04090ab | 26 | DigitalOut col9(P0_12,0); |
matrixmike | 4:0dc3e04090ab | 27 | //DigitalOut myled3(P0_15); // something |
matrixmike | 4:0dc3e04090ab | 28 | |
matrixmike | 1:bd2be1824e78 | 29 | DigitalOut myled1(P0_13); // something |
matrixmike | 1:bd2be1824e78 | 30 | DigitalOut myled2(P0_14); // guessing the layout of the LEDs ATM |
matrixmike | 4:0dc3e04090ab | 31 | DigitalOut myled3(P0_15); // something |
matrixmike | 0:699a0e5dc3ab | 32 | int main() |
matrixmike | 0:699a0e5dc3ab | 33 | { |
matrixmike | 0:699a0e5dc3ab | 34 | while(1) { |
matrixmike | 4:0dc3e04090ab | 35 | // for (int cv = 0; cv < 4 ; cv++) { |
matrixmike | 4:0dc3e04090ab | 36 | // myLedBlink(seq[cv]); |
matrixmike | 4:0dc3e04090ab | 37 | // } |
matrixmike | 4:0dc3e04090ab | 38 | // myled1 = 1; |
matrixmike | 4:0dc3e04090ab | 39 | // myled2 = 1; |
matrixmike | 1:bd2be1824e78 | 40 | myled3 = 1; |
matrixmike | 4:0dc3e04090ab | 41 | // myled4 = 1; |
matrixmike | 0:699a0e5dc3ab | 42 | wait(0.2); |
matrixmike | 4:0dc3e04090ab | 43 | // myled1 = 0; |
matrixmike | 1:bd2be1824e78 | 44 | myled3 = 0; |
matrixmike | 4:0dc3e04090ab | 45 | // myled4 = 0; |
matrixmike | 0:699a0e5dc3ab | 46 | wait(0.2); |
matrixmike | 6:83feebd43ec8 | 47 | // ** |
matrixmike | 5:7881d6e0732f | 48 | myled2 = 1; |
matrixmike | 5:7881d6e0732f | 49 | // myled4 = 1; |
matrixmike | 5:7881d6e0732f | 50 | wait(0.2); |
matrixmike | 5:7881d6e0732f | 51 | // myled1 = 0; |
matrixmike | 5:7881d6e0732f | 52 | myled2 = 0; |
matrixmike | 5:7881d6e0732f | 53 | // myled4 = 0; |
matrixmike | 5:7881d6e0732f | 54 | wait(0.2); |
matrixmike | 6:83feebd43ec8 | 55 | // ** |
matrixmike | 6:83feebd43ec8 | 56 | myled1 = 1; |
matrixmike | 6:83feebd43ec8 | 57 | // myled4 = 1; |
matrixmike | 6:83feebd43ec8 | 58 | wait(0.2); |
matrixmike | 6:83feebd43ec8 | 59 | // myled1 = 0; |
matrixmike | 6:83feebd43ec8 | 60 | myled1 = 0; |
matrixmike | 6:83feebd43ec8 | 61 | // myled4 = 0; |
matrixmike | 6:83feebd43ec8 | 62 | wait(0.2); |
matrixmike | 6:83feebd43ec8 | 63 | // ** |
matrixmike | 2:71c7441b477a | 64 | //} |
matrixmike | 2:71c7441b477a | 65 | // for (int cv = 0; cv < 3 ; cv++) { |
matrixmike | 2:71c7441b477a | 66 | // myLedBlink(cv); |
matrixmike | 2:71c7441b477a | 67 | // } |
matrixmike | 0:699a0e5dc3ab | 68 | } |
matrixmike | 2:71c7441b477a | 69 | } |