Fork of Task344 by
main.cpp@2:695844219cff, 2019-09-18 (annotated)
- Committer:
- noutram
- Date:
- Wed Sep 18 12:18:04 2019 +0000
- Revision:
- 2:695844219cff
- Parent:
- 0:6485cc607fa3
2019
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
noutram | 0:6485cc607fa3 | 1 | #include "mbed.h" |
noutram | 0:6485cc607fa3 | 2 | |
noutram | 2:695844219cff | 3 | #ifdef TARGET_NUCLEO_F429ZI |
noutram | 2:695844219cff | 4 | //#define ONBOARD |
noutram | 2:695844219cff | 5 | #endif |
noutram | 2:695844219cff | 6 | |
noutram | 2:695844219cff | 7 | #ifdef ONBOARD |
noutram | 2:695844219cff | 8 | BusOut binaryOutput(LED1, LED2, LED3); |
noutram | 2:695844219cff | 9 | #else |
noutram | 0:6485cc607fa3 | 10 | //Global objects |
noutram | 0:6485cc607fa3 | 11 | BusOut binaryOutput(D5, D6, D7); |
noutram | 2:695844219cff | 12 | #endif |
noutram | 0:6485cc607fa3 | 13 | |
noutram | 0:6485cc607fa3 | 14 | |
noutram | 0:6485cc607fa3 | 15 | //Main function |
noutram | 0:6485cc607fa3 | 16 | int main() { |
noutram | 0:6485cc607fa3 | 17 | |
noutram | 0:6485cc607fa3 | 18 | //Create a variable to hold the bit pattern |
noutram | 0:6485cc607fa3 | 19 | unsigned int u; |
noutram | 0:6485cc607fa3 | 20 | |
noutram | 0:6485cc607fa3 | 21 | while(1) { |
noutram | 0:6485cc607fa3 | 22 | |
noutram | 0:6485cc607fa3 | 23 | u = 1; //Set initial value 0 |
noutram | 0:6485cc607fa3 | 24 | int count = 0; |
noutram | 0:6485cc607fa3 | 25 | while (count++ < 3) { |
noutram | 0:6485cc607fa3 | 26 | binaryOutput = u; //Write to LEDs |
noutram | 0:6485cc607fa3 | 27 | u = u << 1; //Shift left 1 bit |
noutram | 0:6485cc607fa3 | 28 | wait(0.25); //Wait |
noutram | 0:6485cc607fa3 | 29 | } |
noutram | 0:6485cc607fa3 | 30 | |
noutram | 0:6485cc607fa3 | 31 | //TODO: Make the pattern shift in the opposite direction |
noutram | 0:6485cc607fa3 | 32 | // (also known as the knight rider pattern) |
noutram | 0:6485cc607fa3 | 33 | |
noutram | 0:6485cc607fa3 | 34 | |
noutram | 0:6485cc607fa3 | 35 | } //end while(1) |
noutram | 0:6485cc607fa3 | 36 | } //end main |