EasyManua.ls Logo

Keyestudio ESP32 - 4. Test Result; Project 15: Responder; 1. Description

Keyestudio ESP32
344 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
ESP32 Starter Kit
(continued from previous page)
//set the pin connecting with button to input
pinMode(res,INPUT);
pinMode(add,INPUT);
pinMode(subtract,INPUT);
for(char b=0;b<4;b++){
DigitalTube.clearBit(b); //DigitalTube.clearBit(0 to 3); Clear bit display.
}
}
void loop(){
DigitalTube.displayFloatNum(item);//Digital tube displays item value
int red_key = digitalRead(res); //Red button is the reset button
int yellow_key = digitalRead(subtract); //Yellow button is minus 1
int green_key = digitalRead(add); //Green button is plus 1
if(green_key == 0){
item++; //operate to add 1, item = item + 1
delay(200);
}
if(yellow_key == 0){
item--; //operate to reduce 1, item = item - 1
delay(200);
}
if(red_key == 0){
item = 0;
delay(200);
}
if (item > 9999) { //return to zero when greater than 9999(excessing the display
˓range)
item = 0;
}
}
4. Test Result
After connecting the wiring and uploading code, press green button to add 1, yellow to minus 1, and red to reset. Press
the button and hold it, and the displayed value will keep adding or reducing.
8.5.16 Project 15: Responder
1. Description
This programmable responder inputs and receives signals through Arduino development board and a group of buttons,
and it judges the correctness of answers via a LED. It is a good object to exercise students reaction ability and draw
their attention to questions. If the answer is correct, the respondent obtains a lot scores.
Moreover, it simplifies teachers manipulation of question-grabbers and cuts answer clutters. It may even stimulate
students interests in learning.
96 Chapter 8. Arduino Tutorial

Table of Contents