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.
Fork of max7219ledarray by
Revision 8:880fd42755ca, committed 2017-02-17
- Comitter:
- lore71
- Date:
- Fri Feb 17 07:21:00 2017 +0000
- Parent:
- 7:1f26417a6f51
- Commit message:
- Max7219 8x8 led array with STM32F401RE
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jan 20 11:37:10 2015 +0000
+++ b/main.cpp Fri Feb 17 07:21:00 2017 +0000
@@ -1,8 +1,13 @@
#include "mbed.h"
-// p5: DIN, p7: CLK, p8: LOAD/CS
-SPI max72_spi(p5, NC, p7);
-DigitalOut load(p8);
+// Questo FUNZIONA !!!!
+
+
+// SPI D11 --> DIN
+// SPI D13 --> CLK
+// SPI D10 --> LOAD/CS
+SPI max72_spi(D11, NC, D13);
+DigitalOut load(D10);
int maxInUse = 1; //change this variable to set how many MAX7219's you'll use
@@ -27,26 +32,25 @@
#define MHZ 1000000
void maxSingle( int reg, int col) {
-//maxSingle is the "easy" function to use for a
-//single max7219
+ //maxSingle is the "easy" function to use for a single max7219
load = LOW; // begin
max72_spi.write(reg); // specify register
max72_spi.write(col); // put data
load = HIGH; // make sure data is loaded (on rising edge of LOAD/CS)
}
-void maxAll (int reg, int col) { // initialize all MAX7219's in the system
- load = LOW; // begin
+void maxAll (int reg, int col) {
+ // initialize all MAX7219's in the system
+ load = LOW; // begin
for ( int c=1; c<= maxInUse; c++) {
- max72_spi.write(reg); // specify register
- max72_spi.write(col); // put data
+ max72_spi.write(reg); // specify register
+ max72_spi.write(col); // put data
}
load = HIGH;
}
void maxOne(int maxNr, int reg, int col) {
-//maxOne is for adressing different MAX7219's,
-//while having a couple of them cascaded
+ //maxOne is for adressing different MAX7219's, while having a couple of them cascaded
int c = 0;
load = LOW;
@@ -75,19 +79,17 @@
// max72_spi.frequency(10*MHZ);
maxAll(max7219_reg_scanLimit, 0x07);
- maxAll(max7219_reg_decodeMode, 0x00); // using an led matrix (not digits)
- maxAll(max7219_reg_shutdown, 0x01); // not in shutdown mode
- maxAll(max7219_reg_displayTest, 0x00); // no display test
- for (int e=1; e<=8; e++) { // empty registers, turn all LEDs off
+ maxAll(max7219_reg_decodeMode, 0x00); // using an led matrix (not digits)
+ maxAll(max7219_reg_shutdown, 0x01); // not in shutdown mode
+ maxAll(max7219_reg_displayTest, 0x00); // no display test
+ for (int e=1; e<=8; e++) { // empty registers, turn all LEDs off
maxAll(e,0);
}
- maxAll(max7219_reg_intensity, 0x0f & 0x0f); // the first 0x0f is the value you can set
- // range: 0x00 to 0x0f
+ maxAll(max7219_reg_intensity, 0x00 & 0x0f); // the first 0x0f is the value you can set range: 0x00 to 0x0f
}
void loop () {
-
// //if you use just one MAX7219 it should look like this
// maxSingle(1,1); // + - - - - - - -
// maxSingle(2,2); // - + - - - - - -
@@ -101,8 +103,6 @@
//
//wait(2);
// //if you use more than one MAX7219, it should look like this
-//
-//
// maxAll(1,1); // + - - - - - - -
// maxAll(2,3); // + + - - - - - -
// maxAll(3,7); // + + + - - - - -
@@ -115,26 +115,28 @@
//wait(2);
//maxSingle(11, 7);
-for (int i=0; i<8;i++){
- load = LOW; // begin
- max72_spi.write(i); // specify register
+// Accendo i Leds
+for (int i=0; i<=8;i++){
+ load = LOW; // begin
+ max72_spi.write(i); // specify register
max72_spi.write(0xff); // put data
- load = HIGH; // make sure data is loaded (on rising edge of LOAD/CS)
- //
- wait(0.02);
+ load = HIGH; // make sure data is loaded (on rising edge of LOAD/CS)
+ wait(0.3);
+}
+
+// Spengo i Leds
+for (int i=8; i>0;i--){
+ load = LOW; // begin
+ max72_spi.write(i); // specify register
+ max72_spi.write(0x00); // put data
+ load = HIGH; // make sure data is loaded (on rising edge of LOAD/CS)
+ wait(0.01);
}
-for (int i=8; i>0;i--){
- load = LOW; // begin
- max72_spi.write(i); // specify register
- max72_spi.write(0x00); // put data
- load = HIGH; // make sure data is loaded (on rising edge of LOAD/CS)
- //
- wait(0.02);
-}
- //if you use more then one max7219 the second one should look like this
+
+ //if you use more then one max7219 the second one should look like this
/*
maxOne(2,1,1); // + - - - - - - -
maxOne(2,2,2); // - + - - - - - -
@@ -144,11 +146,7 @@
maxOne(2,6,32); // - - - - - + - -
maxOne(2,7,64); // - - - - - - + -
maxOne(2,8,128); // - - - - - - - +
-
*/
-
- //
-
}
int main() {
