EasyManuals Logo

Freenove Ultimate Starter Kit User Manual

Freenove Ultimate Starter Kit
286 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #157 background imageLoading...
Page #157 background image
157
Chapter 14 Relay & Motor
www.freenove.com
support@freenove.com
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
}
//if changing-state of the button last beyond the time we set,we considered that
//the current button state is an effective change rather than a buffeting
if(millis() - lastChangeTime > captureTime){
//if button state is changed ,update the data.
if(reading != buttonState){
buttonState = reading;
//if the state is low ,the action is pressing
if(buttonState == LOW){
printf("Button is pressed!\n");
relayState = !relayState;
if(relayState){
printf("turn on relay ...\n");
}
else {
printf("turn off relay ...\n");
}
}
//if the state is high ,the action is releasing
else {
printf("Button is released!\n");
}
}
}
digitalWrite(relayPin,relayState);
lastbuttonState = reading;
}
return 0;
}
The code is in the same logic as TableLamp code above.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove Ultimate Starter Kit and is the answer not in the manual?

Freenove Ultimate Starter Kit Specifications

General IconGeneral
BrandFreenove
ModelUltimate Starter Kit
CategorySingle board computers
LanguageEnglish