Joystick Control servo rotation

From Microduino Wiki
Jump to: navigation, search
Language: English  • 中文

Objective

Control servo rotation through Joystick and get correspsonding rotation of the arrow icon in Scratch.

Principle

Read Joystick X-axis values and get servo rovolve to certain angel according to return values.

Equipment

Hardware Buildup

  • Setup 1:Stack CoreUSB and Sensorhub
  • Setup 2:Connect Joystick to analog A0 and A1. There is pin description on two sides of Sensorhub,to which you can connect sensors correspondingly.
  • Setup 3:Connect servo to D8.
Microduino-sensorhub rule.JPG

Software Debugging

  • Setup 1:Build Scratch programming environment.
  • Setup 2:Start programming. Example program download: File:Joystick Servo.zip
  • Setup 3:Code description—detect Joystick values for one part and the arrow icon will make correpsonding movement according to Joystick.
    • You need to create a variable to save Joystick data.
      • Reflect variable values of 0-1023 to 0-180° and control servo through “Motor” plug-in.
Joystick mCookie servo1.gif
    • Rotate the arrow according to variables. (Users can change the arrow icon according to individual needs. )
Joystick mCookie servo2.gif

Result

By moving Joystick on X-axis, you can control servo rotation angle.

Video