I have a fairly simple code to turn a relay on-off every 2 seconds
When i attach the USB of the arduino Uno to the laptop, it goes into a frenzy and the relay triggers on off for 6 times within 3-4 seconds and then it settles down.
This however doesnt happen when connecting directly to the power output.
Is there something that needs to be wired to stop this happening ?
I am using an arduino Uno with a relay JQC-3FF-S-Z connected directly to the arduino pins.
const int ONOFF_TRIGGER_PIN = 2;
void setup() {
// put your setup code here, to run once:
pinMode(ONOFF_TRIGGER_PIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(ONOFF_TRIGGER_PIN, LOW);
delay(2000);
digitalWrite(ONOFF_TRIGGER_PIN, HIGH);
delay(2000);
}