mega pins not working?


i have small dc motor m trying test on mega sketch ive tried few differant pins , nothing happens if hook 5v , grnd on mega works ive tried simple sketch , nothing happens

code: [select]

 int motorpin1 = 3;
int motorpin2 = 4;
void setup(void)
{
  pinmode(motorpin1, output);
  pinmode(motorpin2, output);
}

void loop(void)
  {
   
    digitalwrite(motorpin1, high);
    digitalwrite(motorpin2, low);
}

unless motor tiny (like size of vibrator motor in cellphone) can't draw enough current arduino pin run it.  if wan control speed (but not direction) can use npn transistor between motor , ground act switch.  collector pin goes motor.  emitter pin goes ground. base pin goes arduino pin through resistor (270 ohms good).


Arduino Forum > Using Arduino > Installation & Troubleshooting > mega pins not working?


arduino

Comments