My goal is to make a circuit that can turn on my gas fireplace with a remote control. So I've got the infrared stuff working, but I need to get the relay switching figured out. So I've wired up CIRC-11 circuit, but I can't change the delay of switching (it defaults to 1000 milliseconds) the green and red lights just flip back and forth at the same rhythm. I also can't make the circuit do anything on any other pins besides 2, even though I change the code properly.
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
The circuit:
* LED connected from digital pin 13 to ground.
* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.
Created 1 June 2005
By David Cuartielles
http://arduino.cc/en/Tutorial/Blink
based on an orginal by H. Barragan for the Wiring i/o board
*/
int ledPin = 2; // Relay connected to digital pin 2 <-----Change this to pin 2
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(4000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(4000); // wait for a second
}
Have you accidentally posted the wrong program? That code is just the demo for blinking an LED
Also it does nothing for 1000 millisecs - both delay()s are for 4000 millisecs.
You should not use delay() in any serious program because an Arduino can do nothing during a delay() interval. Use millis() to manage timing. This is illustrated in Planning and Implementing a Program as well as general guidance about developing a program.