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.
main.cpp@0:ea2f8a21085d, 2022-12-04 (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 | } |