1 单词
word | meaning |
---|---|
relay | 继电器 |
water punp | 水泵 |
2 电铃的原理
3 继电器
//加个按钮,然后用开关控制水泵
代码:
2号管脚是按钮
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(5,OUTPUT);
pinMode(2,INPUT_PULLUP);
}
void loop() {
// put yo-ur main code here, to run repeatedly:
digitalWrite(5,!digitalRead(2));
}
4 作业
代码:
led灯管脚为11和12
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(5,OUTPUT);
pinMode(2,INPUT_PULLUP);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
}
void loop() {
// put yo-ur main code here, to run repeatedly:
if(!digitalRead(2))
{
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
}
else
{
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
}
digitalWrite(5,!digitalRead(2));
}