hi,
i having issue controlling small vibration motor push button switch.
i want motor off when switch not pressed, reason still gently vibrates. when press switch vibrates harder - reacting code, reason can't stop vibrating when button isn't pushed!
any suggestions?
here code:
thanks!!
i having issue controlling small vibration motor push button switch.
i want motor off when switch not pressed, reason still gently vibrates. when press switch vibrates harder - reacting code, reason can't stop vibrating when button isn't pushed!
any suggestions?
here code:
code: [select]
const int buttonpin = 9;
const int vibratepin = 8;
int buttonstate = 0;
void setup() {
pinmode(vibratepin, output);
pinmode(buttonpin, input);
}
void loop() {
buttonstate = digitalread(buttonpin);
if (buttonstate == low) {
digitalwrite(vibratepin, high);
}
else {
digitalwrite(vibratepin, low);
}
}
thanks!!
i hope motor not connected directly arduino output pin.
weedpharma
weedpharma
Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Push button + Vibration motor trouble
arduino
Comments
Post a Comment