This circuit is similar to Circuit #12: Spinning a Motor in SIK guide v3.3.
This circuit was confusing at first. You input a number (30 to 255 OR -30 to -255) into the serial monitor then hit enter and the motor will turn forward (or backwards for negative values) based on the number. Small numbers turn the motor slowly and larger numbers turn it faster. I was confused on how to make the switch turn th motor in a different diretion but it ended up being easy. All I did was instead of having just a 0 in the else statement, I wrote 0-motorSpeed to make the value negative if switchPin value was low:
if(digitalRead(7) == LOW){ //if the switch is on...
spinMotor(motorSpeed);
} else{ //if the switch is off...
spinMotor(0-motorSpeed); //reverse motor direction
}
The Landing is a social site for Athabasca University staff, students and invited guests. It is a space where they can share, communicate and connect with anyone or everyone.
Unless you are logged in, you will only be able to see the fraction of posts on the site that have been made public. Right now you are not logged in.
If you have an Athabasca University login ID, use your standard username and password to access this site.
We welcome comments on public posts from members of the public. Please note, however, that all comments made on public posts must be moderated by their owners before they become visible on the site. The owner of the post (and no one else) has to do that.
If you want the full range of features and you have a login ID, log in using the links at the top of the page or at https://landing.athabascau.ca/login (logins are secure and encrypted)
Posts made here are the responsibility of their owners and may not reflect the views of Athabasca University.