Skip to content

Instantly share code, notes, and snippets.

@deviceplususer
Created January 8, 2020 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deviceplususer/61337933985e41e906923422e9a923d7 to your computer and use it in GitHub Desktop.
Save deviceplususer/61337933985e41e906923422e9a923d7 to your computer and use it in GitHub Desktop.
int motorSpeed = analogRead(MOTOR_SPEED);//速度調整つまみの値を取得
if ( motorSpeed > 10 )//つまみの値が一定以上なら
{
motorSpeed = map( motorSpeed, 10, 1023, 40, 255 );//つまみの値をスピードに変換
motor1.drive( motorSpeed );//指定したスピードでモーターを回す
} else {
motor1. brake();//つまみの値が一定以下ならモーターを止める
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment