tap tempo with attiny85

I recently found a project for the attiny85, it is a tap tempo that is basically to measure an average of times between pulses of a switch, well the code that I found is very explained and detailed only that when compiling I get errors, I hope that can you help since I’m not good at this
-I attach the code and the link of the page from where I obtained for more information

https://scientificguitarist.wixsite.com/home/pt2399-tap-tempo

EchoWreck.ino (13.7 KB)

Gotta post the error, my man.
I advice you to go to your Arduino IDE, go to File->Preferences, and change compiler warning to all.
When the IDE gives you error, copy ALL the error, and paste it with code tags (Top right of reply window, this icon: </>)

linearity64:
Gotta post the error, my man.
I advice you to go to your Arduino IDE, go to File->Preferences, and change compiler warning to all.
When the IDE gives you error, copy ALL the error, and paste it with code tags (Top right of reply window, this icon: </>)

Excuse me, I am new to this forum, I did not understand you correctly, but here I leave the error copied as you said

linearity64:

Arduino:1.8.13 (Windows 10), Tarjeta:"ATtiny25/45/85, ATtiny85, Internal 1 MHz"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\PROPIETARIO\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\PROPIETARIO\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\PROPIETARIO\Documents\Arduino\libraries -fqbn=attiny:avr:ATtinyX5:cpu=attiny85,clock=internal1 -ide-version=10813 -build-path C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766 -warnings=all -build-cache C:\Users\PROPIE~1\AppData\Local\Temp\arduino_cache_777752 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\PROPIETARIO\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\PROPIETARIO\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\PROPIETARIO\Documents\Arduino\libraries -fqbn=attiny:avr:ATtinyX5:cpu=attiny85,clock=internal1 -ide-version=10813 -build-path C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766 -warnings=all -build-cache C:\Users\PROPIE~1\AppData\Local\Temp\arduino_cache_777752 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino

Using board ‘ATtinyX5’ from platform in folder: C:\Users\PROPIETARIO\AppData\Local\Arduino15\packages\attiny\hardware\avr\1.0.2

Using core ‘arduino’ from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used…

“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=1000000L -DARDUINO=10813 -DARDUINO_attiny -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Users\PROPIETARIO\AppData\Local\Arduino15\packages\attiny\hardware\avr\1.0.2\variants\tiny8” “C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766\sketch\EchoWreck.ino.cpp” -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Generating function prototypes…

“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=1000000L -DARDUINO=10813 -DARDUINO_attiny -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Users\PROPIETARIO\AppData\Local\Arduino15\packages\attiny\hardware\avr\1.0.2\variants\tiny8” “C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766\sketch\EchoWreck.ino.cpp” -o “C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766\preproc\ctags_target_for_gcc_minus_e.cpp” -DARDUINO_LIB_DISCOVERY_PHASE

“C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags” -u --language-force=c++ -f - --c+±kinds=svpf --fields=KSTtzns --line-directives “C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766\preproc\ctags_target_for_gcc_minus_e.cpp”

Compilando programa…

“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=attiny85 -DF_CPU=1000000L -DARDUINO=10813 -DARDUINO_attiny -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Users\PROPIETARIO\AppData\Local\Arduino15\packages\attiny\hardware\avr\1.0.2\variants\tiny8” “C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766\sketch\EchoWreck.ino.cpp” -o “C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766\sketch\EchoWreck.ino.cpp.o”

C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino: In function ‘void loop()’:

EchoWreck:140:6: error: expected ‘(’ before ‘updateDTime’

if updateDTime {

^~~~~~~~~~~

In file included from C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766\sketch\EchoWreck.ino.cpp:1:0:

C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino: In function ‘void updateDelayTime()’:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:96:26: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

#define round(x)    ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

~^

C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino:238:23: note: in expansion of macro ‘round’

tempDelayTime = round(tapTime/multiplier);

^~~~~

EchoWreck:247:5: error: ‘updateDTime’ was not declared in this scope

updateDTime = 1;

^~~~~~~~~~~

C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino:247:5: note: suggested alternative: ‘updateDelayTime’

updateDTime = 1;

^~~~~~~~~~~

updateDelayTime

C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino: In function ‘void checkTapTempo()’:

C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino:294:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

if (currDelay < tapTimeout) {

^~

In file included from C:\Users\PROPIE~1\AppData\Local\Temp\arduino_build_134766\sketch\EchoWreck.ino.cpp:1:0:

C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino: In function ‘void updateLED()’:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:96:26: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

#define round(x)    ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

~^

C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino:379:27: note: in expansion of macro ‘round’

currLEDOnInterval = round(delayTime / 2);

^~~~~

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:96:26: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

#define round(x)    ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

~^

C:\Users\PROPIETARIO\Desktop\EchoWreck\EchoWreck.ino:381:26: note: in expansion of macro ‘round’

currLEDOffInterval = round(delayTime - currLEDOnInterval);

^~~~~

exit status 1

expected ‘(’ before ‘updateDTime’

carlozsulc:
Excuse me, I am new to this forum, I did not understand you correctly, but here I leave the error copied as you said

It's fine.
I ran through the code a bit, and found out the code is missing declaration of 'updateDTime' for some reason, as indicted by the error log:

EchoWreck:247:5: error: 'updateDTime' was not declared in this scope
     updateDTime = 1;
     ^~~~~~~~~~~

So you can add that somewhere in global ( the part before void setup() ).

uint8_t updateDTime = 0;

The second error is indicated here by the error log:

expected '(' before 'updateDTime'

This line, for some reason, doesn't have brackets:

if updateDTime {
    updatePWM();
}

So you can add the brackets, and it should compile

if (updateDTime) {
    updatePWM();
}

linearity64:
It's fine.
I ran through the code a bit, and found out the code is missing declaration of 'updateDTime' for some reason, as indicted by the error log:

EchoWreck:247:5: error: 'updateDTime' was not declared in this scope

updateDTime = 1;
    ^~~~~~~~~~~



So you can add that somewhere in global ( the part before void setup() ).


uint8_t updateDTime = 0;



The second error is indicated here by the error log:


expected '(' before 'updateDTime'



This line, for some reason, doesn't have brackets:


if updateDTime {
   updatePWM();
}



So you can add the brackets, and it should compile


if (updateDTime) {
   updatePWM();
}

compiled !!!! Thank you very much for the help