when one turns to the specified position the other one moves and then makes weird noises and resets the arduino
here is the code:
#include <Servo.h>
Servo myservo;
Servo myservo2;
void setup() {
pinMode(13, OUTPUT );//led and beeper
pinMode(2, INPUT );//start switch
pinMode(8, OUTPUT );//relay
myservo.attach(9);//servo
myservo2.attach(12);//servo2
myservo.write(95);//base position
myservo2.write(-25);//base position
digitalWrite(8, LOW);//relay off
digitalWrite(13, HIGH);//flashes to indicate that the marshmallow is ready to be loaded
delay(1000 * 0.5);
digitalWrite(13, LOW);
}
void loop() {
if (digitalRead (2) == HIGH) { // if you press the start button:
digitalWrite(13, HIGH); //it flashes because it turns the lever with the marshmallow on it
delay(1000 * 0.5);
digitalWrite(13, LOW);
delay(1000 * 0.5);
delay(1000 * 0.5);//wait a while
myservo.write(13);//turns the knob
digitalWrite(8, HIGH); //start rotating and roasting...
delay(1000*60);
digitalWrite(13, HIGH);//ready!!!
delay(1000 * 0.5);
digitalWrite(13, LOW);
myservo.write(95);//turns the knob
delay(1000 * 0.2);
digitalWrite(8, LOW);//stops rotation (which rotates the marshmallow)
delay(1000 * 0.5); //wait...
digitalWrite(13, HIGH);//flashes that the marshmallow is ready
delay(1000 * 0.5);
digitalWrite(13, LOW);
delay(1000 * 0.5);
digitalWrite(13, HIGH);
delay(1000 * 0.5);
digitalWrite(13, LOW);
delay(1000 * 0.5);
//you're all set: you can buy the marshmallows :)
}
}
It sounds like a power supply issue. The Arduino cannot supply enough power for servos, motors, or 4x relays. If too much power/current is drawn from USB, either the PC will give an error message and cut the power, or the voltage will drop causing the Arduino to reset.
You should post a schematic, your photos do not show everything.
You seem to supply two servos and the relayboard all from the Arduino 5V-pin.
There are a lot of un-professional examples online that show supplying servos from the Arduino 5V-pin.
This does not work reliably as you have encountered. Resetting the Arduino is a very typical sympton of a shutdown of the 5V-voltage-regulator.
You should always power the servos like shown in this picture
With its own power-supply that is able to deliver enough current.
by the way:
your pictures show a candle and a wooden stick that seems to be light-up = catching fire through the candle.
I hope you are using your device only inside a un-burnable box under permanent observation of a minimum 18 year person. And that you have a fire extinguisher 1m next to your device and know how to use it.
If you are a 13 to 16 year old. It is very likely that you underestimate the riscs of your device and you would be sorry for the rest of your life if somebody would die from a fire caused by your riscy experiments.
Think about this:
of course you can't make deals with the devil. Just as a thought experiment:
If you could bring back a died person to life that died through a fire that you have caused
How often would you invest time into fireprotection-security?
I'm very sure once every week 2 hours if it would really bring back the person to life.
Now make a deal with your Guardian Angel to add high security against fire.
@StefanL38
you are right
but it won't get infected because it has marshmallows on it and I wet the wood before each use.
but what you say is valid.
and by the way I am 12 years old ,
and I have a fire extinguisher in my room
How about using a stick that is made out of steel?
Do you have a smoke-detector with a 100 db loud sirene/beeper in the middle of your ceiling?
reliable smoke-detector devices start at $15
after looking again at your pictures.
The planetary gear outputshaft is out of steel. You extended it - I guess with hotglue and a wooden stick. Well if the front end is made out of steel the higher thermal conductivity might melt the hotglue connection.
At the place where you live is there some kind of steel good shop? Or a DIY-shop?
A threaded rod out of stainless steel would be a good option.
Do you have a drilling machine and a set of thread drills?