版权声明:(谢厂节的博客)博主文章绝大部分非原创,转载望留链接。 https://blog.csdn.net/xundh/article/details/83691532
代码
/**********************************************/
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
}
/*************************************************/