Table of Contents

() motor ()

Description

() motor () block is a stack block available in actuators extension for evive and all Arduino boards. The block free or locks the motor connected to the selected slot from evive, Arduino Uno, Mega & Nano.

Input Parameters

  1. Motor stopping action:
    1. Lock: This means that both the motor output pins will be HIGH, resulting in stopping the motor. But in this case, the motor also resists any rotational movement. This is like the brake.
    2. Free:  This means that both the motor output pins will be LOW, resulting in stopping the motor. But in this case, the motor if free for any rotational movement. This is like the clutch.
  2. Motor channel:
    1. evive: The motor channel can be motor channel 1 or motor channel 2.
      evive motor channel
    2. Arduino Uno, Mega, and Nano: The motor channel can be 1-4 depending on which channel has been initialized previously using connect motor () direction 1 () direction 2 () & PWM () block.
evive Notes Icon
Note: This block is available in both Upload mode and Stage mode.

Example

  1. This script locks and frees the motor.

run motor example upload mode

Example

Learn how to control speed of the motor using Arduino and motor driver.
interfacing motor driver with Arduino

Arduino is a controlling device not a power source on the other hand, motors work on the principle of electromagnetism and hence draw a lot of load current which can’t be maintained by Arduino. To overcome this, we need a motor driver which maintains this load current along with the speed and direction control of the motor.

Circuit

connections

connection. 

Arduino uno            Motor driver

D5                             IN1

D4                             IN2

D6                             EN1

GND                          GND

Code

  • Create a variable as speed and set it 0

  • From actuators drag connect motor () direction 1() direction 2() and PWM()

  • from controls palette add a forever block

  • again from controls palette add if-then-else block in the forever block

  • We will be changing the speed using th up and down arrow. For this goto sensing and check for the key pressed.

  •  from Acturatos add run motor() direction () with speed()

  • Inset the value of the speed variable as motor speed

  • Repeat the above steps for the down arrow to reduce the speed. 

  • Add a wait block for a time of 0.25 seconds in forever block outside the if-then-else block.

  • now from the event palette add when flag clicked event at the start of the script.

Script

Output

Read More
All articles loaded
No more articles to load