Vidyasagar Academy Wishes a Very Happy, Healthy & Prosperous Diwali to all our Students & Teachers!
- Arduino Alvik: How to write the blinking LED code?
- How to write code for alternate Blinking LEDs with different colors in Arduino Alvik?
- How to move Arduino Alvik forward and backward using simple code?
- How to give turns to Arduino 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. using simple code?
- Achieving control and orientation with Arduino Alvik on rotating platform
- Simple black line follower code for Arduino Alvik
Join Online/Offline short term course to learn advanced programming of Arduino Alvik at Vidyasagar Academy. Register now at this link.
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.
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.?
Turning the Alvik is very simple. It is called pivot turn. There 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.