I have not written the code yet. Here is what I want to happen. I am controlling DC MOTOR using 2 dp relays, one is dc= the other is dc -. When switch a is thrown, a led will come on and relay 1 will be energized. I want the relay ot be energized for milliseconds and then turn off while the led will stay on. What command would i use to energize the relay and the shut it off?
Time to start writing your code yourself. Look at blink example for inspiration...
Also a relay is not the best option for milliseconds of contact...
digitalWrite()
See Using millis() for timing. A beginners guide, Several things at the same time and the BlinkWithoutDelay example in the IDE
Divide the project in small steps:
.1. Wire a pushbutton to an LED: Vcc >> button in - button out >> 220 ohm resistor >> LED(+) - LED(-) >> GND
Pushbutton should make LED light. After that works...
.2. Wire the control end of a relay to a pushbutton: Vcc >> button in - button out >> RelayVcc (and) RelayGnd >> GND (and) Vcc/5Vdc >> button in - button out >> RelayIN
Pushbutton should energize relay. After that works...
.3. Wire the switched end of the relay to light an LED (use 5vdc for now): Vin >> RelayNC (and) GND >> RelayCOM (and) RelayNO >> 220 ohm resistor >> LED(+) - LED(-) >> GND
Pushbutton should energize relay and light LED.
.4. Code the relay to turn on and off
/*
relay on/off
WIRING
Arduino 5vdc to relay +
Arduino GND to relay -
Arduino D03 to relay S (signal)
*/
// assign a digital pin to switch the relay
const int RELAY_PIN = 3;
void setup() {
// initialize digital pin as an output.
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW); // for N.O. relay open (not conducting)
}
void loop() {
digitalWrite(RELAY_PIN, HIGH); // close the relay
delay(1000);
digitalWrite(RELAY_PIN, LOW); // open the relay
delay(1000);
}
The relay should be clicking once a second. After that works...
.5. Code the Arduino to read a HIGH or LOW level from the pushbutton, then light the LED and toggle the relay. My relay does not respond to "1ms" toggle.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.