Arduino Alvik

How to give turns to Arduino Alvik using simple code?

This entry is part 4 of 5 in the series Arduino Alvik

If you are already familiar with Arduino Alvik environment, then you can proceed with the following post. However, if you are new to Arduino Alvik, then we suggest you to read this post on Arduino Alvik basics first!

As we know there are two motors on the bottom of the Arduino Alvik. Let us see how to control these motors and move the robot in different directions.

Arduino Alvik

How to turn AlvikArduino Alvik Arduino Alvik is a unique and innovative development platform, designed to expand the capabilities of the Arduino ecosystem by incorporating MicroPython as its primary programming language. Alvik focuses on offering a versatile environment for building projects that require advanced features such as real-time control, robotic automation, and sensor-based systems.?

pivot turns to Arduino Alvik

Turning the Alvik is very simple. It is called pivot turnThere are four possible ways in which we can give turns to the Alvik robot. Note that the following piece of codes are given as per the modules that you import in your code.

from arduino_alvik import ArduinoAlvik
from time import sleep_ms

Start your code with above two lines to use the following piece of codes to turn the Arduino Alvik.

Soft left turn

To turn the Alvik with soft left turn, just make the right motor parameter as 0 and set the left motor parameter as per your choice of speed.

Here note that you will have to give delay also below the command of soft left turn, as follows:

alvik.set_wheels_speed(0, 50) # turn left at angular speed 50
sleep_ms(2600) # this delay will turn Arduino Alvik almost in 90 degrees

Soft right turn

For soft right turn, just make the left motor parameter as 0 and set the right motor parameter as per your choice of speed.

Here note that you will have to give delay also below the command of soft right turn, as follows:

alvik.set_wheels_speed(50, 0) # turn right at angular speed 50
sleep_ms(2600) # this delay will turn Arduino Alvik almost in 90 degrees

If your Arduino Alvik is running on some soft or slippery surface, you may have to slightly adjust the delay parameter.

Power left turn

The trick behind giving a power turn to Arduino Alvik, just change the sign of speed parameter of any one motor. Let us see how to give power left turn to the Arduino Alvik. There should be some delay to get proper turn to Arduino Alvik.

alvik.set_wheels_speed(-50, 50) # power left turn at angular speed 50
sleep_ms(800) # this delay will turn Arduino Alvik almost in 90 degrees

Power right turn

To give power right turn, use following piece of code. There should be some delay to get proper turn to Arduino Alvik.

alvik.set_wheels_speed(50, -50) # power right turn at angular speed 50
sleep_ms(800) # this delay will turn Arduino Alvik almost in 90 degrees

Stop motors

To stop the motors of Arduino Alvik, just use the following default functionMeaning of function in coding A function in any programming language is defined as the group of commands to carry out a particular task. It is necessary to note that all the commands in a function will execute a particular task, together..

alvik.brake()
sleep_ms(1000) # some delay to stop it

The Code

The following code is freely available for logged in users.

Signup or Login to view remaining content. It's Completely Free!
Share on your network!
Dattaraj Vidyasagar
Dattaraj Vidyasagar

Author on this website. He is veteran of Core Electronics since last 36+ years. ATL Mentor of Change, Niti Ayog, Govt. of India, Google Certified Educator, International Robotics Trainer and author of 18 books on electronics, robotics, programming languages and web designing... ➤➤

Leave a Reply

Your email address will not be published. Required fields are marked *