倾斜传感器是一种可检测较小倾斜角度的电子开关,当垂直悬挂的倾斜开关探头在受到外力作用且偏离垂直位置17°以上时,倾斜开关内部的金属球触电断开;当外力撤销后,倾斜开关恢复到垂直状态同时金属球触点也恢复到闭合状态。

Arduino引脚

模块引脚

D3

S

5V

VCC

GND

GND

 1 int led = 13;
 2 int buttonPin = 3;
 3 int val;
 4 void setup() {
 5   // put your setup code here, to run once:
 6   pinMode(led, OUTPUT);
 7   pinMode(buttonPin, INPUT);
 8 }
 9 
10 void loop() {
11   // put your main code here, to run repeatedly:
12   val = digitalRead(buutonPin);
13   if (vaa == HIGH)
14   {
15     digitalWrite(led, HIGH);
16   } esle{
17     digitalWrite(led, LOW);
18   }
19 }

 

相关文章:

  • 2021-10-03
  • 2021-10-29
  • 2021-11-06
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-25
  • 2021-12-09
  • 2021-11-27
  • 2021-07-26
  • 2021-09-14
  • 2021-05-05
  • 2022-12-23
相关资源
相似解决方案