I'm having problems with regards of coding my TM1637 display. I always get error when compiling my file. Can someone help me with the code since I'm a beginner in using arduino.
Firmware.ino (8.01 KB)
I'm having problems with regards of coding my TM1637 display. I always get error when compiling my file. Can someone help me with the code since I'm a beginner in using arduino.
Firmware.ino (8.01 KB)
Please post the full text of the error message that you get
This is the error that I get. The problem is that I really don't know what to put there
Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino: In function 'void setup()':
Firmware:56:29: error: expected primary-expression before numeric constant
display.writeByte(uint8_t 0);
^
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino: In function 'void loop()':
Firmware:82:31: error: expected primary-expression before numeric constant
display.writeByte(uint8_t 0);
^
Firmware:93:15: error: 'class TM1637Display' has no member named 'writebyte'; did you mean 'writeByte'?
display.writebyte(uint8_t 0);
^~~~~~~~~
writeByte
Firmware:93:33: error: expected primary-expression before numeric constant
display.writebyte(uint8_t 0);
^
Firmware:100:7: error: 'finalTime' was not declared in this scope
finalTime = millis() - time0;
^~~~~~~~~
Firmware:110:7: error: 'finalTime' was not declared in this scope
finalTime = (millis() - time0) / 10;
^~~~~~~~~
Firmware:111:33: error: expected primary-expression before 'finalTime'
display.writeByte(uint8_t finalTime);
^~~~~~~~~
Firmware:118:7: error: 'finalTime' was not declared in this scope
finalTime = (millis() - time0) / 10;
^~~~~~~~~
Firmware:120:7: error: 'piezoSpeaker' was not declared in this scope
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:120:7: note: suggested alternative: 'PiezoSpeaker'
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~
PiezoSpeaker
Firmware:120:31: error: 'piezoSpeakerHoorayLength' was not declared in this scope
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:120:31: note: suggested alternative: 'piezoSpeaker_5vHoorayLength'
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~
piezoSpeaker_5vHoorayLength
Firmware:120:57: error: 'piezoSpeakerHoorayMelody' was not declared in this scope
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:120:57: note: suggested alternative: 'piezoSpeaker_5vPlayMelody'
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~
piezoSpeaker_5vPlayMelody
Firmware:120:83: error: 'piezoSpeakerHoorayNoteDurations' was not declared in this scope
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:120:83: note: suggested alternative: 'piezoSpeaker_5vPlayNoteDurations'
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
piezoSpeaker_5vPlayNoteDurations
Firmware:128:31: error: expected primary-expression before 'finalTime'
display.writeByte(uint8_t finalTime);
^~~~~~~~~
Multiple libraries were found for "TM1637Display.h"
Used: C:\Users\acer\Documents\Arduino\libraries\TM1637-master
exit status 1
expected primary-expression before numeric constant
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
display.writeByte(uint8_t 0);
Remove the type specifier from this function call
I removed it and now I'm getting this error
Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino: In function 'void setup()':
Firmware:56:22: error: 'bool TM1637Display::writeByte(uint8_t)' is protected within this context
display.writeByte(0);
^
In file included from C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:8:0:
C:\Users\acer\Documents\Arduino\libraries\TM1637-master/TM1637Display.h:152:9: note: declared protected here
bool writeByte(uint8_t b);
^~~~~~~~~
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino: In function 'void loop()':
Firmware:82:24: error: 'bool TM1637Display::writeByte(uint8_t)' is protected within this context
display.writeByte(0);
^
In file included from C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:8:0:
C:\Users\acer\Documents\Arduino\libraries\TM1637-master/TM1637Display.h:152:9: note: declared protected here
bool writeByte(uint8_t b);
^~~~~~~~~
Firmware:93:15: error: 'class TM1637Display' has no member named 'writebyte'; did you mean 'writeByte'?
display.writebyte(0);
^~~~~~~~~
writeByte
Firmware:100:7: error: 'finalTime' was not declared in this scope
finalTime = millis() - time0;
^~~~~~~~~
Firmware:110:7: error: 'finalTime' was not declared in this scope
finalTime = (millis() - time0) / 10;
^~~~~~~~~
Firmware:118:7: error: 'finalTime' was not declared in this scope
finalTime = (millis() - time0) / 10;
^~~~~~~~~
Firmware:120:7: error: 'piezoSpeaker' was not declared in this scope
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:120:7: note: suggested alternative: 'PiezoSpeaker'
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~
PiezoSpeaker
Firmware:120:31: error: 'piezoSpeakerHoorayLength' was not declared in this scope
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:120:31: note: suggested alternative: 'piezoSpeaker_5vHoorayLength'
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~
piezoSpeaker_5vHoorayLength
Firmware:120:57: error: 'piezoSpeakerHoorayMelody' was not declared in this scope
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:120:57: note: suggested alternative: 'piezoSpeaker_5vPlayMelody'
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~
piezoSpeaker_5vPlayMelody
Firmware:120:83: error: 'piezoSpeakerHoorayNoteDurations' was not declared in this scope
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\acer\Downloads\Firmware\Firmware\Firmware.ino:120:83: note: suggested alternative: 'piezoSpeaker_5vPlayNoteDurations'
piezoSpeaker.playMelody(piezoSpeakerHoorayLength, piezoSpeakerHoorayMelody, piezoSpeakerHoorayNoteDurations);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
piezoSpeaker_5vPlayNoteDurations
Firmware:128:23: error: 'finalTime' was not declared in this scope
display.writeByte(finalTime);
^~~~~~~~~
Multiple libraries were found for "TM1637Display.h"
Used: C:\Users\acer\Documents\Arduino\libraries\TM1637-master
exit status 1
'bool TM1637Display::writeByte(uint8_t)' is protected within this context
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
TM1637Display::writeByte(uint8_t)' is protected within this context
The compiler does not lie.
Here is a portion of TM1637Display.h
protected:
void bitDelay();
void start();
void stop();
bool writeByte(uint8_t b);
What exactly are you trying to do by calling the writeByte() function ?
What I wanted the command to do was for the timer to start when the glass gets lifted and then show the final time for when the fsr receive resistance from the glass. To be honest, I have no idea whether I should use that command or not but the compiler suggested that I replace my former command which is s7s.writeInt(0) with writeByte. Oh, by the way, the original project used a sparkfun 7 segment serial display so the original code was based on it. I switched to a TM1637 display since I can't have my hands on the sparkfun display.
Go back to basics. Can you write text to the display ?
Did the library come with any examples ?
the compiler suggested that I replace my former command which is s7s.writeInt(0) with writeByte
Where did you get the idea of using writeInt() in the first place and what is writing 0 supposed to do ?
The code came from the original project that I saw online. I downloaded the code and changed some. It was my first time using the tm1637 display so I read the manual for it, but unfortunately, I don't know know how to implement it in the code from the code that came from the original project.
Did the library come with any examples ?
I just opened the library for it and, yes, there is an example. I'll try running it and see what I can use in here.
So I ran the test for the TM1637, I still have no idea what to use. I just want to make a stopwatch with the fsr as the trigger.
What did the test output to the display ?
Static numbers and characters from each command separated by delay. There was no example for a timer or stopwatch so I'm still clueless on what command I should use. I've also been looking up commands for stopwatch but unfortunately, it's not for TM1637.
Static numbers and characters from each command separated by delay.
Then it is working and it shows you how to write numbers to the display
So, how do you implement a stopwatch ? Well, you need to count timeframes such as seconds and minutes and start/stop the counting using the force sensitive resistor.
Start with the fsr. Do you know how to connect it to the Arduino and read the value from it ? If not the search for fsr in this forum. I am fairly sure that you will find examples of how to read the value and display it on the Serial monitor
Oh, I think I should do that first. So, I searched online about the millis command. Should I be using that for the code of the stopwatch?
So, I searched online about the millis command. Should I be using that for the code of the stopwatch?
Yes. Have a look at Using millis() for timing. A beginners guide, Several things at the same time and look at the BlinkWithoutDelay example in the IDE, but concentrate on reading the FSR and displaying the value on the Serial monitor first. Do not try to write the whole program at once.
Thanks for your advice. I'll study more about the uses of millis and try to apply it on my works. I hope I can get by with this since I have to pass this as my project for one subject on thursday. Thank you again for keeping in touch with me! I might reply here again if I hit a wall again.
Forget about timing and millis() unless you can read the FSR output