ESP32 Starter Kit
(continued from previous page)
int addition = 32; //Set the plus button to IO32
int subtraction = 33; //Set the minus button to IO33
int start = 34; //Set the start button to IO34
int reset = 35; //Set the reset button to IO35
int buzz = 26; //Set the buzzer to IO26
int buzz_val = 1; //The variable of buzzer
void printByte(byte character []) //The dot matrix display function
{
int i = 0;
for(i=0;i<8;i++)
{
lc.setRow(0,i,character[i]);
}
}
void setup(){
lc.shutdown(0,false); //MAX72XX is in power saving mode when starting
lc.setIntensity(0,8); //Set the brightness to the maximum
lc.clearDisplay(0); //Clear the display
//Set the pin mode
pinMode(addition,INPUT);
pinMode(subtraction,INPUT);
pinMode(start,INPUT);
pinMode(reset,INPUT);
pinMode(buzz,OUTPUT);
for(char b=0;b<4;b++){
DigitalTube.clearBit(b); //DigitalTube.clearBit(0 to 3); Clear bit display.
}
}
void loop(){
printByte(smile); //Dot matrix displays a smile face
DigitalTube.displayFloatNum(item); //Digital tube displays the item value
int blue_key = digitalRead(addition); //Read the button value
int green_key = digitalRead(subtraction);
int yellow_key = digitalRead(start);
if(blue_key == 0){ //Determine whether the button is pressed
item = item + 1; //+1
delay(200);
}
if(green_key == 0 ){
item = item - 1; //-1
delay(200);
}
if (item > 9999) { //When the value is greater than 9999(exceeding the display range),
˓→ reset
item = 0;
}
(continues on next page)
8.5. Arduino Project 103