代码
/**********************************************/
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
}
/*************************************************/
接线图

相关文章:
-
2021-08-28
-
2021-10-28
-
2021-11-01
-
2021-09-10
-
2021-11-13
-
2022-12-23
-
2021-04-09
-
2021-11-06