简单的继电器控制与Arduino
问题描述:
我是Arduino编码的新手。过去我已经完成了Java和Matlab。简单的继电器控制与Arduino
我设计了一个简单的回放电路在这里看到:
我认为它是树立正确的,但如果没有,请让我知道。
我基本上需要简单的代码来无限期地触发继电器开启和关闭,间隔时间为1秒,或者直到我断开电源。
任何帮助将是伟大的。
谢谢!
答
您可以简单地使用Arduino IDE附带的Blink示例。将继电器输出控制连接到引脚13(你的黄线),你有它。
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
更好的办法是使用闪烁无延迟例如
你可能会更好过,询问在http://arduino.stackexchange.com/ – David 2014-10-30 22:55:42