Yuichi Tateno
/
Max7219_7segled_example
Max7219 7segled example
main.cpp@0:d50f30be8280, 2016-09-24 (annotated)
- Committer:
- hotchpotch
- Date:
- Sat Sep 24 08:22:08 2016 +0000
- Revision:
- 0:d50f30be8280
init
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hotchpotch | 0:d50f30be8280 | 1 | #include "mbed.h" |
hotchpotch | 0:d50f30be8280 | 2 | #include "Max7219.hpp" |
hotchpotch | 0:d50f30be8280 | 3 | |
hotchpotch | 0:d50f30be8280 | 4 | int main() { |
hotchpotch | 0:d50f30be8280 | 5 | SPI spi(D11 /* MOSI */, NC, D13 /* SCK */); |
hotchpotch | 0:d50f30be8280 | 6 | MAX7219 max7219(spi, D10 /* CS */); |
hotchpotch | 0:d50f30be8280 | 7 | max7219.begin(); |
hotchpotch | 0:d50f30be8280 | 8 | max7219.print("-1234.567"); |
hotchpotch | 0:d50f30be8280 | 9 | |
hotchpotch | 0:d50f30be8280 | 10 | wait(5); |
hotchpotch | 0:d50f30be8280 | 11 | double counter = 0.0f; |
hotchpotch | 0:d50f30be8280 | 12 | char num_str[10]; |
hotchpotch | 0:d50f30be8280 | 13 | |
hotchpotch | 0:d50f30be8280 | 14 | while(1) { |
hotchpotch | 0:d50f30be8280 | 15 | counter += 0.01; |
hotchpotch | 0:d50f30be8280 | 16 | sprintf(num_str, "%9.2f", counter); |
hotchpotch | 0:d50f30be8280 | 17 | max7219.print(num_str); |
hotchpotch | 0:d50f30be8280 | 18 | } |
hotchpotch | 0:d50f30be8280 | 19 | } |