Hi everyone.
I'm testing this seven segments library in order to further make a clock.
I am using the following code, which is in the library's user guide:
When I compile it for UNO I don't have any problems, but when I run it for Leonardo (the board I have) I got this message:
Arduino:1.6.4 (Windows 8.1), Placa:"Arduino Leonardo"
C:\Users\Felipe\Documents\Arduino\libraries\SevenSeg\SevenSeg.cpp: In member function 'void SevenSeg::startTimer()':
C:\Users\Felipe\Documents\Arduino\libraries\SevenSeg\SevenSeg.cpp:133:5: error: 'TCCR2A' was not declared in this scope
TCCR2A = 0;
^
C:\Users\Felipe\Documents\Arduino\libraries\SevenSeg\SevenSeg.cpp:134:5: error: 'TCCR2B' was not declared in this scope
TCCR2B = 0;
^
C:\Users\Felipe\Documents\Arduino\libraries\SevenSeg\SevenSeg.cpp:135:5: error: 'TCNT2' was not declared in this scope
TCNT2 = 0; // Initialize counter value to 0
^
C:\Users\Felipe\Documents\Arduino\libraries\SevenSeg\SevenSeg.cpp:136:5: error: 'OCR2A' was not declared in this scope
OCR2A = 3; // Set Compare Match Register to 3
^
C:\Users\Felipe\Documents\Arduino\libraries\SevenSeg\SevenSeg.cpp:137:21: error: 'WGM21' was not declared in this scope
TCCR2A |= (1 << WGM21); // Turn on CTC mode
^
C:\Users\Felipe\Documents\Arduino\libraries\SevenSeg\SevenSeg.cpp:138:21: error: 'CS22' was not declared in this scope
TCCR2B |= (1 << CS22); // Set prescaler to 64
^
C:\Users\Felipe\Documents\Arduino\libraries\SevenSeg\SevenSeg.cpp: In member function 'void SevenSeg::stopTimer()':
C:\Users\Felipe\Documents\Arduino\libraries\SevenSeg\SevenSeg.cpp:158:5: error: 'TCCR2B' was not declared in this scope
TCCR2B = 0;
^
Error de compilación
Can anybody help me figure out what's going wrong? I think it's something on the library, but I don't know how to fix this.
The Arduino Uno uses the ATmega328P microcontroller, and the Arduino Leonardo uses the ATmega32U4 microcontroller which does not have TIMER2. Often TIMER4 is used instead of TIMER2.
It means that the library is not suitable for the Arduino Leonardo. I'm sorry, but it is not going to work. You should find another library for 7-segment display.
gardab:
Hi everyone.
I'm testing this seven segments library in order to further make a clock.
I am using the following code, which is in the library's user guide:
Can anybody help me figure out what's going wrong? I think it's something on the library, but I don't know how to fix this.
Where is the rest of your code? At a quick glance, I see a function called setTimer(id) which lets you choose the timer you want.
Try adding "disp.setTimer (0);" to the start of your code (right after this line):
Well, there is no "rest of the code". It is exactly the sample code that is in the users guide, in this pdf in page 5.
I added the line Krupski said, but now I get only this error, both in UNO and Leonardo.
Arduino:1.6.4 (Windows 8.1), Placa:"Arduino Uno"
SevenSeg:3: error: 'disp' does not name a type
'disp' does not name a type
Is there a way to fix this? maybe in the library itself?
But that isn't going to work. The third line there is an executable function call, not a declaration. The call to the function setTimer(), of the disp object, has to be inside some other function, normally setup( )
But that isn't going to work. The third line there is an executable function call, not a declaration. The call to the function setTimer(), of the disp object, has to be inside some other function, normally setup( )
You will actually need something more like this:
Well, I put the setTimer function and commented the lines reffering to timer2 in the library, now I don't get any error message, but the circuit does nothing, not even a blink on a segment.
I guess is useless keep trying to fix this with this library.