Landing : Athabascau University
  • Blogs
  • SIK Guide v4.0a - Project 5A: Motor Basics

SIK Guide v4.0a - Project 5A: Motor Basics

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
}