hey guys,
new arduino have been looking past few months @ examples , practicing on own guide of examples. me major working on senior design project ramping speed on 12v dc motor 0 100% once momentary push button engaged. have motor hooked 12v source in parallel diode , small capacitor. these 3 input npn transistor motor @ collector , ground @ emitter. have arduino output (pin 10) hooked base of transistor 1k resistor between protect arduino current coming 12v source. have momentary push button receiving power arduino 5v source , providing input arduino @ pin 9.
my issue when push switch, motor turns on not shut off. have tried adding while loop (which commented out @ end) motor not run @ when this.
here code far
thanks help,
kyle
new arduino have been looking past few months @ examples , practicing on own guide of examples. me major working on senior design project ramping speed on 12v dc motor 0 100% once momentary push button engaged. have motor hooked 12v source in parallel diode , small capacitor. these 3 input npn transistor motor @ collector , ground @ emitter. have arduino output (pin 10) hooked base of transistor 1k resistor between protect arduino current coming 12v source. have momentary push button receiving power arduino 5v source , providing input arduino @ pin 9.
my issue when push switch, motor turns on not shut off. have tried adding while loop (which commented out @ end) motor not run @ when this.
here code far
code: [select]
//set pin numbers
const int pushbutton = 9; // seat engaged push button attached pin 9
const int transistor = 10; // digital output sent transistor pin 10
int buttonstate = 0; // variable reading pushbutton, high when pressed
int motorstate = 0; // value of state of motor, high when throttle engaged
void setup() {
// initialize transistor output
pinmode(transistor, output);
// initialize pushbutton input
pinmode(pushbutton, input);
}
void loop() { // put main code here, run repeatedly:
// read state of pushbutton
buttonstate = digitalread(pushbutton);
// while engaged ramp power transistor
while(buttonstate == high) {
// ramp analog voltage signal transistor
int = 0;
if (i < 255) {
analogwrite(transistor,i);
= + 1;
delay(10);
}
if (i = 255) {
analogwrite(transistor,255);
delay(10);
}
}
//while(buttonstate == low) {
// analogwrite(transistor,0);
//}
}
thanks help,
kyle
is push button input floating?
Arduino Forum > Using Arduino > Programming Questions > Push button DC Motor Control - Ramp up Speed
arduino
Comments
Post a Comment