Error when trying to control dc motor

i was trying to control my dc motor today, when i tested the code, this error showed up:

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
Failed uploading: uploading error: exit status 1

The error indicates your operating system and the IDE lost contact with the Arduino. You should supply power to the motors separate from supplying power to the Arduino. My guess is that you were trying to supply the motors with power from the Arduino, and caused the Arduino to reboot. Post a drawing of your project to identify the items, a picture of the wiring and the sketch you are using.



here is my code and my wiring

Disconnect everything from the Arduino, except the USB plug and try to upload the blink example program.

DO NOT attempt to power a motor or servo from the Arduino, as that can damage the Arduino, and be sure to ignore any tutorials that suggest it is OK to do so.

Use a separate power supply, like a phone charger, and don't forget to connect all the grounds.
This example for a servo gives you the basic idea:

Here are a few simple rules that will help you from replacing your Arduinos:
Gil's Crispy Critter Rules, they apply to processor hardware:
Rule #1. A Power Supply the Arduino is NOT!
Rule #2. Never Connect Anything Inductive to an Arduino!
Rule #3 Don't connecting or disconnecting wires with power on.
Rule #4 Do not apply power to any pin unless you know what you are doing.
LaryD's Corollarys
Coro #1 when first starting out, add a 220R resistor in series with both Input and Output pins.
Coro #2 buy a DMM (Digital Multi-meter) to measure voltages, currents and resistance.
Violating these rules tends to make crispy critters out of Arduinos.

Several comments have already addressed rule #1, best to follow it.

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