代码

/**********************************************/
const int keyPin = 13; //the "s" of relay module attach to
const int laserPin = 7;
/**********************************************/
void setup()
{
  pinMode(laserPin, OUTPUT); //initialize relay as an output
  pinMode(keyPin, INPUT);
}
/***********************************************/
void loop()
{
  boolean Value=digitalRead(keyPin);
  if(Value==HIGH){
    digitalWrite(laserPin, LOW); //disconnect the relay   
  }else
    digitalWrite(laserPin, HIGH); //Close the relay
}
/*************************************************/


接线图

Arduino 入门学习笔记5 按键控制激光发生器

相关文章:

  • 2021-08-28
  • 2021-10-28
  • 2021-11-01
  • 2021-09-10
  • 2021-11-13
  • 2022-12-23
  • 2021-04-09
  • 2021-11-06
猜你喜欢
  • 2021-10-26
  • 2021-08-24
  • 2022-01-01
  • 2022-01-19
  • 2022-12-23
  • 2021-05-29
  • 2022-12-23
相关资源
相似解决方案