Keyestudio ARDUINO maker learning kit Manual page 89

Table of Contents

Advertisement

Vibration
switch
Sample program
//////////////////////////////////////////////////////////
#define SensorLED
#define SensorINPUT
unsigned char state = 0;
void setup()
{
pinMode(SensorLED, OUTPUT);
pinMode(SensorINPUT, INPUT);
attachInterrupt(0, blink, FALLING);//D2 as external interruption 0, when there is falling trigger
and call blink function
}
void loop()
{
if(state!=0)
{
digitalWrite(SensorLED,HIGH);
delay(3000);
state = 0;
}
else
digitalWrite(SensorLED,LOW);
}
void blink()// digital input of the sensor falling, triggering interruption function
keyestudio
13
2
www.keyestudio.cc
87

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ARDUINO maker learning kit and is the answer not in the manual?

Table of Contents