Go Down

Topic: Arduino restarts sketch before completion. (Read 546 times) previous topic - next topic

Hello all,

I'm very new to Arduino. I've assembled some simple circuts with success, (motion detectors, motors, ect.), just as experiments, and I decided I was ready for an actual project.  I have an antique telegraph sounder that works perfectly, and I wanted to use the Arduino to generate some random ticking noises.  At the moment the sketch is just a bunch of "Dot" and "Dash" functions (both glorified "blink" sketches in function format) repeated to make it tap out "Hello World." 

I have the telegraph sounder hooked up to the 3v3 pin (it needs about 3v to work) through a physical relay connected to pin 12.  This setup works perfectly the first time through, but as it repeats, the test LED (pin 13) flashes, and the entire sketch seems to restart.  It usually gets about as far as the "e" in "hello" before  restarting.  When the telegraph sounder is replaced with a normal LED everything works fine. What does the Arduino not like about the sounder? Is it drawing too much current from 3v3?

This seemed a bit more like a problem with the Arduino than just "Project Guidance", so I'm putting it here.  Sorry if it's in the wrong place.

Thanks!

HazardsMind

Please post pictures and your FULL code.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

AWOL

Quote
I have the telegraph sounder hooked up to the 3v3 pin
...which is good for about 50mA.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Grumpy_Mike

Have you a reverse biased diode across the relay? - You need one.
Are you using a transistor to drive the relay, if not what current does it take?

I've attached a close up of the Arduino and the breadboard, containing the relay.

@ Grumpy_Mike:  Yes, I have a diode across the relay.  I'm not sure how much current it takes.

Here's the code.  The main program is in void setup() because I only want it to happen once.  The same problem occurs if it is in void loop() as well.
Code: [Select]

int led = 12;
void dot(){
    digitalWrite(led,HIGH);
    delay(100);
    digitalWrite(led,LOW);
    delay(300);
}
void dash(){
  digitalWrite(led,HIGH);
  delay(400);
  digitalWrite(led,LOW);
  delay(300);


void setup() {               
  pinMode(led, OUTPUT);
  dot();
  dot();
  dot();
  dot();
  delay(600);
  dot();
  delay(600);
  dot();
  dash();
  dot();
  dot();
  delay(600);
  dot();
  dash();
  dash();
  delay(600);
  dash();
  dash();
  dash();
  delay(600);
  dot();
  dash();
  dot();
  delay(600);
  dot();
  dash();
  dot();
  dot();
  delay(600);
  dash();
  dot();
  dot();
}

void loop() {
 

Grumpy_Mike

That is not an arduino is it. So do you know the specification of the current capability of the 3V3 supply?

I asked:-
Quote
Are you using a transistor to drive the relay, if not what current does it take?

No answer. It will help to know if you are killing your board by pulling too much current out of the pin to drive the relay.

How much current does your telegraph sounder take. That is most likely your problem.

Quick note: I've also noticed that when it resets, the test LED flashes exactly as if I had pressed the reset button.

@ Grumpy_Mike Sorry, got the names messed up.  I'm not using a transistor.  It's a DKduino, which is exactly the same, just a bit cheaper and with a few extra pins. (As far as I know.) I'm trying to find out how much current is going through it, but my multimeter is acting up.  If that is my problem, is there a simple way to solve it, or will I need a much more complicated circuit?

Thanks for all the help.

zoomkat

Quote
No answer. It will help to know if you are killing your board by pulling too much current out of the pin to drive the relay.


I don't think the OP "gets it".  :smiley-roll:
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Grumpy_Mike

Quote
It's a DKduino, which is exactly the same,

No it is not exactly the same, it is a different board and has different proprieties.

Quote
I'm trying to find out how much current is going through it, but my multimeter is acting up

Arh!!!
You should know how much current a thing draws BEFORE you connect it up not after!!!
So how do you know you are not drawing too much from the Arduino. This is a very good way to fry it.

When you remove the telegraph sounder and just here the click of the relay does it still reset?
Do not do the experiment until you can confirm that the relay when connected directly across 5V and ground draws no more than 40mA.

Nick Gammon

Quote
DSCN3052.JPG (3119.69 KB, 4608x3456 - viewed 16 times.)


That's a 3 Mb download just to show a picture of your board. As a courtesy to forum users, you could resize down to a more reasonable size, like 100Kb.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

Quote
What does the Arduino not like about the sounder? Is it drawing too much current from 3v3?


Probably. You might save some money by getting your meter fixed and measuring the current drain before hooking it up to your board.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up