DC-motors doesn't work when attaching Servo


i've started project make autonomous car.
the problem have when attach servomotor vehicle 1 wheel stopps working. first thought might have been power issue, thing though servo isn't connected pin, wheel stopps working when upload code.

i'm running vehicle on 9v battery.
arduino uno
arduino sensorshield v5.0
l298n motor driver

it works when comment "myservo.attach(3)".

void setup() {
    for(int i=0;i<2;i++) {
    pinmode(rw,output);
    pinmode(lw,output);
    pinmode(speed,output);
    }
    pinmode(trigpin,output);
    pinmode(echopin,input); 
    pinmode(13,output);
   // myservo.attach(3);

}

void loop() {

      for(int i=0;i<2;i++) {
        analogwrite(speed,200);
      }
        digitalwrite(rw[0],high);
        digitalwrite(lw[0],high);
        digitalwrite(rw[1],low);
        digitalwrite(lw[1],low);
}

please use code tags (</> button on toolbar) when post code or warning/error messages. reason forum software can interpret parts of code markup, leading confusion, wasted time, , reduced chance problem. make easier read code , copy ide or editor. using code tags , other important information explained in how use forum post. please read it.

please tools > auto format on code before posting it. make easier spot bugs , make easier read. if you're using arduino web editor not have access useful tool. recommend use standard ide instead.

is there part of sketch forgot post? please post of code.


Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > DC-motors doesn't work when attaching Servo


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts