I am using a tutorial from Last Minute Engineers (In-Depth: Interfacing MAX7219 LED Dot Matrix Display with Arduino)
2nd example near bottom of page. I am getting a few error messages that I cannot find guidance on the Arduino help pages. The following is the code then after the code are the error messages. I used the Manage Libraires to load the called for packages and it now says these are on the board.
Any assistance you can provide would be most helpful.
Terry
void setup() {
// put your setup code here, to run once:
}
void loop() {
// Including the required Arduino libraries
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Uncomment according to your hardware type
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
//#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
// Defining size, and output pins
#define MAX_DEVICES 8
#define CS_PIN 3
// Create a new instance of the MD_Parola class with hardware SPI connection
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
void setup() {
// Initialize the object
myDisplay.begin();
// Set the intensity (brightness) of the display (0-15)
myDisplay.setIntensity(0);
// Clear the display
myDisplay.displayClear();
myDisplay.displayScroll("Hello", PA_CENTER, PA_SCROLL_LEFT, 100);
}
void loop() {
if (myDisplay.displayAnimate()) {
myDisplay.displayReset();
}
}
}
C:\Users\Terry Younce\Dropbox\My PC (DESKTOP-K3AT0PC)\Documents\Arduino\sketch_jun8a\sketch_jun8b\sketch_jun8b.ino: In function 'void loop()':
C:\Users\Terry Younce\Dropbox\My PC (DESKTOP-K3AT0PC)\Documents\Arduino\sketch_jun8a\sketch_jun8b\sketch_jun8b.ino:22:16: error: a function-definition is not allowed here before '{' token
void setup() {
^
C:\Users\Terry Younce\Dropbox\My PC (DESKTOP-K3AT0PC)\Documents\Arduino\sketch_jun8a\sketch_jun8b\sketch_jun8b.ino:35:15: error: a function-definition is not allowed here before '{' token
void loop() {
^
exit status 1
Compilation error: a function-definition is not allowed here before '{' token
It's hard to see your problem, but easy to guess.
Use the IDE Autoformat tool on your code.
Then use the IDE Copy for Forum tool, and come here and paste it. It should then look like code we can read:
void setup() {
}
void loop() {
}
This will help spot the missing or misplaced { braces }.
You can also use the <CODE> button in the message composition window and
type or paste code here
do what it says after you press it.
TIA
a7
2 Likes
Easy to spot, but he needs to learn to follow instructions.
It appears the problem is much more important then taking the time to read the guidelines. As the OP is finding out we cannot see what he can and the guide lines are there only to help us help the OP.
I used auto format and the Code button on the code in the original post. I used these two tools again in this reply.
Terry
```cpp
void setup() {
// put your setup code here, to run once:
}
void loop() {
// Including the required Arduino libraries
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Uncomment according to your hardware type
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
//#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
// Defining size, and output pins
#define MAX_DEVICES 8
#define CS_PIN 3
// Create a new instance of the MD_Parola class with hardware SPI connection
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
void setup() {
// Initialize the object
myDisplay.begin();
// Set the intensity (brightness) of the display (0-15)
myDisplay.setIntensity(0);
// Clear the display
myDisplay.displayClear();
myDisplay.displayScroll("Hello", PA_CENTER, PA_SCROLL_LEFT, 100);
}
void loop() {
if (myDisplay.displayAnimate()) {
myDisplay.displayReset();
}
}
}
type or paste code here
You should have an error from the extra setup() and loop(). delete those and an extra } and it should at least compile.
// Including the required Arduino libraries
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Uncomment according to your hardware type
//#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
// Defining size, and output pins
#define MAX_DEVICES 8
#define CS_PIN 3
// Create a new instance of the MD_Parola class with hardware SPI connection
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
void setup() {
// Initialize the object
myDisplay.begin();
// Set the intensity (brightness) of the display (0-15)
myDisplay.setIntensity(0);
// Clear the display
myDisplay.displayClear();
myDisplay.displayScroll("Hello", PA_CENTER, PA_SCROLL_LEFT, 100);
}
void loop() {
if (myDisplay.displayAnimate()) {
myDisplay.displayReset();
}
}
That resolved the error issues,
Thanks,
Terry
Haha, it looks like you took the text literally
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
And placed a full sketch, which had its own setup() and loop(), where the empty sketch you started with said
// put your main code here, to run repeatedly:
Please take time to understand what you did wrong, and why @oldcurmudgeon's editing fixed things up.
If you don't understand at least the basic structure of a sketch, you just gonna keep getting in trouble.
And you did not post the code quite right, I can't tell what you did, maybe you used both pasting methods, I dunno. At least you failed to paste over the already selected "type or paste code here"
This appears when you hit the <CODE> button:
```
type or paste code here <- paste your code over this.
```
It expects code you brought over by selecting it all in the IDE and just normal copying it.
a7
If you want to check your braces are balanced then click the cursor on the opening brace and the closing brace will have a small box around it. In this way you can see if this is where you expect it to be. If it is not, then you have either too many or too few braces.
1 Like
I had the display up and running in a few minutes after editing as you suggested. Thank You. Do you have any experience with the MAX 7219 I am working with? I would like to feed the text in from an existing vintage driver sending 12 pin parallel probably RS 232. I bought a converter from this to USB to feed into the Arduino board but I expect that there is some new commands I will need to add to the existing software to make this happen.
Any suggestions?
Thanks, Terry
With 12 pins it is definitely not RS 232. What type display used the 12 pin interface? If it is a character mode display you need to capture the characters and send them to the MAX7219 via the library. The library takes care of converting the characters to the correct dot pattern.
The Parola_Scrolling example receives input from the serial interface and scrolls it onto the matrix display. This may be a good starting point for your code.
The original display I am trying to replace has 16 complete displays each consisting of 12 lines, the 7 for alpha, an X and a vertical line in the center. All are laminated between 2 about 1/8 inch peace's of glass. It is then mounted on a driver PC board at about 90 degrees along one edge. It was built in the early 1990s by Nova Production from the UK. It has a 12 pin connector on the board with a ribbon cable coming from the main board. The reason I thought it was RS232 is when I order a converter from 12 pin to USB there were 2 types RS232 and RS432 or something like that. I figured as old as it was it must be 232. The original display shows alpha, numbers and big Xes. I can use the new display as is but I will need 2 cards with 2 different messages then switch between with a relay but if it is possible to take data from the original main driver card it would be a more elegant way to have the display work. The only thing that works from the original main board is the text on the display. This is for an old "game" called the Bromley Shocker, made in the Chicago area with all the electronics coming from the UK. Nova the board makers from the UK are still in business but are not offering any support for game. you put your money in, you grab ahold of chrome handles, and as the game starts you feel a vibration of the handles. This advances as the number of Jolts, rather than Volts increases to 2000 Jolts, there is also smoke toward the end and you get a souvenir card at the end. I am using a PLC to control all the functions including sounds in time with the text display. There are 3 levels of vibration you feel through the chrome handles. Anyway thanks for your willingness to give me straight answers, you thoughts.
Terry:
Post some pictures. Particularly the display board ICs. The interface is probably non standard. In those days there weren't many standards and companies did their own. They may have used the same hardware design for multiple games.
here are a couple of photos of the old display board.
The 74LS273 chips are octal latches - probably used to store the characters. The ULN parts are probably display drivers. The 74LS244 is a bus driver/buffer chip. The interface is definitely proprietary.
The with the display was a bad connection of some kind to one of the display segments. If I heated up one of that sections leads to the board it would connect when I removed the heat it would loose the connection again. The solder joint at the board looks good, I suspect something inside the display it's self. I managed to short something out and the whole thing stopped working. I can see dark on 3 pins of one of the ULN6118 chips, there was also some smoke. There had been previous soldering on some of the display pins. So I think I will try using 2x Arduino UNO boards one that will run a teaser then when game starts that will start and switch, the signal line to a 2nd board with the show text.
Thanks,
Terry
Never a good thing. Smoke means you have seriously fried the part. You might be able to repair it but your soldering skills do not seam up to it.
Many beginners make this this mistake, you are only making things more difficult for yourself.
I have been trying to configure one of my new R3 boards. but I am getting a message that says :
avrdude: ser_open(): can't open device "\.\COM4": The system cannot find the file specified.
Failed uploading: uploading error: exit status 1
My computer shows the new board as an Unknown device. When I move the USB cable to the original board it shows as an Arduino Uno on com 4. As far as I can tell both boards have the same software installed including :
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
both of these from the library. as well as Arduino Uno R4 software which is on both the new and old boards.
Terry
I solved the problem, by restarting my computer a couple of times and using the Device Manager to manually set the com port to 4.
Terry