Arduino 入门学习笔记4 继电器实验

版权声明:(谢厂节的博客)博主文章绝大部分非原创,转载望留链接。 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
}
/*************************************************/

电路:

在这里插入图片描述

实验效果

在这里插入图片描述

程序运行起来,可以听到继电器卡塔卡塔声音。

猜你喜欢

转载自blog.csdn.net/xundh/article/details/83691232