版权声明:(谢厂节的博客)博主文章绝大部分非原创,转载望留链接。 https://blog.csdn.net/xundh/article/details/83691232
程序
const int relayPin =7; //the "s" of relay module attach to
/**********************************************/
void setup()
{
pinMode(relayPin, OUTPUT); //initialize relay as an output
}
/***********************************************/
void loop()
{
digitalWrite(relayPin, HIGH); //Close the relay
delay(1000); //wait for 1 second
digitalWrite(relayPin, LOW); //disconnect the relay
delay(1000); //wait for 1 second
}
/*************************************************/
电路:
实验效果
程序运行起来,可以听到继电器卡塔卡塔声音。