C:\Users\USER\Documents\Arduino\4_digit\4_digit.ino: In function 'void setup()':
4_digit:32:13: error: a function-definition is not allowed here before '{' token
void loop() {
^
4_digit:99:1: error: expected '}' at end of input
}//loop
^
exit status 1
a function-definition is not allowed here before '{' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I'm still a beginner and still learning, please help. thank you
#include <TM1637Display.h> // include TM163 library
#define CLK 2 // define TM1637 clock pin
#define DIO 3 // define TM1637 data pin
#define UP 4 // define up button pin
#define DN 5 // define down button pin
#define RST 6 // define reset button pin
// Create a display object of type TM1637Display
TM1637Display display = TM1637Display(CLK, DIO);
int num = 0, prev_num = 1;
byte
last_up,last_dn, last_rst;
void setup() {
// initialize the TM1637 display
init();
// set display brightness (from 0 to 7)
(4);
pinMode(UP, INPUT);
last_up = digitalRead( UP );
pinMode(DN, INPUT);
last_dn = digitalRead( DN );
pinMode(RST, INPUT);
last_rst = digitalRead( RST );
//main loop
void loop() {
static unsigned long
timeButton=0;
unsigned long
timeNow;
byte
button;
//read the buttons every 50mS
timeNow = millis();
if( timeNow - timeButton >= 50ul )
{
timeButton = timeNow;
button = digitalRead( UP );
if( button != last_up )
{
last_up = button;
if( button == HIGH )
{
num++; // increment 'num'
if(num > 1000)
num = 0;
}//if
}//if
button = digitalRead( DN );
if( button != last_dn )
{
last_dn = button;
if( button == HIGH )
{
num--; // increment 'num'
if(num < 0)
num = 1000;
}//if
}//if
button = digitalRead( RST );
if( button != last_rst )
{
last_rst = button;
if( button == HIGH )
{
num = 0;
}//if
}//if
if(num != prev_num)
{
// if the displayed (current) number was changed
prev_num = num; // save current value of 'num'
// print all data
tm1637.display(0, num/1000); // print thousands digit
tm1637.display(1, num/100 % 10); // print hundreds digit
tm1637.display(2, num/10 % 10); // print tens digit
tm1637.display(3, num% 10); // print ones digit
//delay(200); // wait 200 milliseconds
}//if
}//if
}//loop