Luis Silvio Cordova Rivadeneira
/
Max7219_7LED_example
Ejemplo para ver com,unicacion SPI simple
Ejemplo de blog en repositorio
ejemplo de imagen subida
main.cpp@1:81db1068fe7d, 2020-02-05 (annotated)
- Committer:
- lscordovar
- Date:
- Wed Feb 05 21:58:22 2020 +0000
- Revision:
- 1:81db1068fe7d
- Parent:
- 0:d50f30be8280
ejemplo de SPI; 7 segmentos
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() { |
lscordovar | 1:81db1068fe7d | 5 | SPI spi(PB_5 /* MOSI */, PB_4, PB_3 /* SCK */); |
lscordovar | 1:81db1068fe7d | 6 | MAX7219 max7219(spi, PD_7 /* 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 | } |