The problem is that i have two servos connected and they are interfering with each other

when one turns to the specified position the other one moves and then makes weird noises and resets the arduino :frowning:
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 :)

  }



}



here are two photos of the machine :slight_smile:


i hope i have written enough information for you to help me. thanks in advance :slight_smile:

sorry if what i write is strange but i use a translator (deepl translator) which is good but sometimes it translates weird :slight_smile:

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.

2 Likes

I looked onto your picture

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
grafik
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.

best regards Stefan

1 Like

how can i do that ? on what website ?

Pencil and paper. Common sense. Draw it, shoot a picture and post it here.

Draw all components and how you have them hooked up. Including any power supplies &c.

Google

 Electronic schematic diagram

to get a feel for it, but don't obsess. Just give it a try pretend like you know what you are doing.

a7

@StefanL38
you are right :slight_smile:
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 :slight_smile:

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

no🤨

Note: The valid range of inputs for .write() is 0 to 180. The value -25 is not valid and will probably be treated as zero.

thanks for the help :slight_smile:

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?

A small block out of aluminium with two threads M3 / M4 as the connection between shaft and threaded rod

replaced with metal :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.