Dar Leg
/
ubitRandomBlink
Microbit random LED matrix blink
main.cpp@0:ea2f8a21085d, 18 months ago (annotated)
- Committer:
- appa
- Date:
- Sun Dec 04 20:05:25 2022 +0000
- Revision:
- 0:ea2f8a21085d
microbit random led matrix
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
appa | 0:ea2f8a21085d | 1 | #include "mbed.h" |
appa | 0:ea2f8a21085d | 2 | |
appa | 0:ea2f8a21085d | 3 | DigitalOut C[] = {(COL1), (COL2),(COL3)}; |
appa | 0:ea2f8a21085d | 4 | DigitalOut R[] = {(ROW1), (ROW2),(ROW3)}; |
appa | 0:ea2f8a21085d | 5 | |
appa | 0:ea2f8a21085d | 6 | int main() { |
appa | 0:ea2f8a21085d | 7 | int col = 0; |
appa | 0:ea2f8a21085d | 8 | int row = 0; |
appa | 0:ea2f8a21085d | 9 | |
appa | 0:ea2f8a21085d | 10 | while(1) { |
appa | 0:ea2f8a21085d | 11 | col = rand() % 2; |
appa | 0:ea2f8a21085d | 12 | row = rand() % 2; |
appa | 0:ea2f8a21085d | 13 | C[col] - 0; |
appa | 0:ea2f8a21085d | 14 | R[row] = 1; |
appa | 0:ea2f8a21085d | 15 | wait(0.9); |
appa | 0:ea2f8a21085d | 16 | R[row] = 0; |
appa | 0:ea2f8a21085d | 17 | C[col] = 1; |
appa | 0:ea2f8a21085d | 18 | } |
appa | 0:ea2f8a21085d | 19 | } |