fbpx
Magicblocks Lesson 17: Sever motor control
MagicBlocks Project

Lesson 17: Sever motor control [Magicblocks]

Introduction

Hello and Welcome, This short tutorial will teach you how to control sever motors with  Magicbit using Magicblocks.

Magicblocks is easy visual programming software to program your Magicbit. Anyone can program their microcontroller by using magicblocks.io  and there is no need for programming knowledge. You can sign up for free.

Start and Open the Playground.

Set up servo node

  • Drag & drop the Servo block from the magicbit nodes section on the left of the screen to the Flow.
  • Double-click on the Servo block and change the Device id and pin

The Servo motor can be rotated from 0 to 180 degrees, depending on the manufacturing. This degree of rotation can be controlled by applying 0 to 180 values to the servo node. for that, we can use inject /slider /etc.

Methode 1

Insert inject block

  • Drag & drop the inject block from the input nodes section on the left of the screen to the Flow.
  • Double-click on the inject block and change the payload as a num.
  • change the values to control the servo motor. (0*/90* 180*) and change the names

and add more inject nodes.

Deploy program

• Click on the Deploy button on the top right-hand corner of the screen.

Click the buttons and see the motor rotation.

Annotation 2022-09-12 102030.png

Methode 2

we can control the servo motor using a potentiometer

  • Setting Up the Analog In Block and Range block
  • Drag & drop the Analog In block and Range block on the left of the screen to the Flow.
  • Double-click on the Analog In block.
    • Select your unique Device ID from the drop-down menu.
    • select pin as POT(39) from the drop-down menu.
    • Select Method as Interrupt from the drop-down menu.

Set up the Range Block

  • Double-click on the Range block and change the input and output result ranges. potentiometer gives an analog voltage input from 0 to 3.3V and it converts to a digital value of 0 to 4095. but for the sever motor we use 0 to 180 values.

Deploy program

• Click on the Deploy button on the top right-hand corner of the screen.

you can control servo motor angle using the potentiometer.

 

If you need help with the steps, feel free to follow our video tutorial on Youtube.

Related Posts
Leave a Reply