Table of Contents
[BlocksExtension]

connected bluetooth on serial () at baudrate ()

Description

Connected bluetooth on serial () at baudrate () is a stack block available in Dabble extension for Arduino Mega. The Oscilloscope module allows you to visualize the input and output signals of your hardware device on your smartphone. This block for setting the baud rate of the Bluetooth module that you have connected to Arduino Mega.

Input Parameters

  1. Select the serial channel from the drop-down list on which you can connect the Bluetooth module.
  2. Select the baud rate from the drop-down list.

evive Notes Icon

Note: This block is available only in Upload mode.

Example

In the given script we will visualize the voltage level across an analog pin on Mega. Mega Oscilliscope

Example

Learn about the 4x4 keypad module's working principle and applications. Explore how to interface a 4x4 keypad module with Arduino using Pictoblox.
Introduction

A 4×4 keypad module is an electronic input device commonly used in various applications for interfacing with microcontrollers and other digital systems. It consists of a grid of buttons arranged in a 4×4 matrix, resulting in a total of 16 buttons. Each button corresponds to a specific alphanumeric character, symbol, or command.

Working Principle: A technique called “keypad scanning” is used to read input from the keypad. The microcontroller scans the rows and columns one by one. It sets one row to HIGH and reads the column pins to detect if any button in that row is pressed. If a button is pressed, the corresponding row and column will intersect, allowing the microcontroller to determine the button that was pressed.

Applications: 4×4 keypad modules are widely used in various applications that require user input, such as security systems, door locks, industrial control panels, calculators, home automation, and more.

In this example, we will be interfacing the keypad module with Arduino and try to read the button value from the keypad module. let’s begin!!

Circuit diagram

Code

  1. Open pictoblox and create a new file.
  2. from boards, select Arduino Uno.
  3.  change Scripting mode from stage to upload.
  4. from extension button add “communication” extension and “Advance sensor” extension.
  5. create a variable “key value” of type string.
  6. From Arduino palette, add “When Arduino Starts up” block into the scripting area.
  7. From advanced sensors, Drag initilize keypad module block and add with above block.
  8. Now we need to start the Serial communication for Arduino. From the communication palette add Now from variable palette, add “set () to ()” block with above block “Set Serial()  baud rate to ()” in the script and set baud rate to 9600.
  9. Now from variables, we block “set () to ()” select the key value from the list and remove the  0 (make a empty string variable).
  10.  Add a forever loop from controls palette.
  11. Now from advanced sensors store the value of key pressed in key value variable.
  12.  Add a if block from controls palette into the scripting area and add greater than operator from operator palette.
  13.  Now if the length of key value operator is greater than 0, that means the user has pressed a key.  Use lenght of ( ) block from operators
  14.  Inside this if block we will be print the key value on Serial monitor using the communication palette. use the block “write () on Serial ()” from communication palette and place the key value variable in the space provided.
  15. Now delete all the data of key value variable using “set () to ()” block from variables.
  16. add this if block in forever block.

in this way we can connect our keypad module with Arduino.

 

Output:

OUTPUT GIF will be updated soon.

 

Read More
Learn about the 4x4 keypad module's working principle and applications. Explore how to interface a 4x4 keypad module with Arduino using Pictoblox.

Introduction

A 4×4 keypad module is an electronic input device commonly used in various applications for interfacing with microcontrollers and other digital systems. It consists of a grid of buttons arranged in a 4×4 matrix, resulting in a total of 16 buttons. Each button corresponds to a specific alphanumeric character, symbol, or command.

Working Principle: A technique called “keypad scanning” is used to read input from the keypad. The microcontroller scans the rows and columns one by one. It sets one row to HIGH and reads the column pins to detect if any button in that row is pressed. If a button is pressed, the corresponding row and column will intersect, allowing the microcontroller to determine the button that was pressed.

Applications: 4×4 keypad modules are widely used in various applications that require user input, such as security systems, door locks, industrial control panels, calculators, home automation, and more.

In this example, we will be interfacing the keypad module with Arduino and try to read the button value from the keypad module. let’s begin!!

 

This is sequential example of keypad in which we are going to make a password-based door lock system.  In part 1 we learned how to interface keypad with Arduino. click here to access part 1

 

Circuit diagram

Code

Here we will continue updating th script that we created in part 1. Click here to access previous script.

  1. Open the script from part 1.
  2. Create 2 String type variables as “my password” and “password”.  Store your password in “my password variable” and make password as empty variable as shown
  3.  From variables add block “set () to ()” in if block. Choose “password ” from the list and add an addition operator in the space provided.
  4.  Inside the addition operator, place password in the first space and key value in second space. as shown.
  5. Add another if block after “set key value to ()” block.
  6. Since password is a combination of multiple characters, so here we have to check for the length of our password whether it is equally to the length of our password that we have set in “my password” variable or not. If yes, then we will be comparing “password” with “my password”. for this use equality operator from operators.
  7. Now from operators use the  ‘Length if ()” block for finding thee length of both the passwords and do the comparison. as shown.
  8. If the length of both the variables is equal then we have to check for the password matching.For this add if-then-else block inside this if block. as shown.
  9. Here use the equality operator for password matching.
  10. If the user has entered the correct password then the servo motor must move from  0 to 90 degrees for 3 seconds. Otherwise, the servo must be at 0 degrees. 
  11. AFter the password compression, delete the data of the “password” variable.
  12. You can also add the messages for the user as ‘access granted” or access denied” as per the result of password comparison.
  13.  Create a block and name it as “password matching”. add the above blocks of code under this block.
  14.  Use this block in our main script. 

In this way, we can set any security password in our script and then can easily make a password-based security system.

 

Output

Read More
We will use the Adafruit IO cloud service to send data from a humidity and temperature sensor to the cloud.

We will use the Adafruit IO cloud service to send data from a humidity and temperature sensor to the cloud. Adafruit IO is a cloud service that allows you to send data from sensors and other devices to the cloud, where it can be stored and analyzed.

Adafruit IO Key

You can find the information about your account once you log in from here:

Note: Make sure you are login on Adafruit IO: https://io.adafruit.com/

DHT Sensor Connection to Quarky

DHT sensors have 3 pins: GND, VCC, and Signal. You have to connect the following 3 pins to the Quarky Expansion Board:

  1. GND to Ground Pin of Quarky Expansion Board
  2. VCC to 3.3V or VCC Pin of Quarky Expansion Board
  3. Signal to the D3 (Digital Pin) of the Quarky Expansion Board

Script

The following feeds are created:

Creating Dashboard

Follow the steps:

  1. Go to the dashboard and click on New Dashboard.
  2. Add the Dashboard Name and Description and click on Create.
  3. Open the New Dashboard. Click on the Setting icon in the top right corner and then click on Create New Block.
  4. From the options, click on the line chart.
  5. Select the Temperature Feed and click on Next Step.
  6. Add the Block Title and the Y-Axis Minimum – Maximum value. Click on Create Block.
  7. You will find the block added on the dashboard.
  8. Add a Humidity block as well. Also, add two gauge elements showing the current temperature and humidity value.
  9. Click on the Setting button and Edit Layout to align all the buttons.
Read More
Learn how to use PictoBlox to control the predefined motions of the Quadruped robot.

Introduction

In this project, we will explain how to run predefined motions in PictoBlox for the Quadruped. The predefined motions allow users to make the robot move forward, backward, left, right, and much more.

Quadruped Motions

The are eight predefined motions for Quarky in PictoBlox which can be accessed through do () motion () times at () speed block. Using the do () motion () times at () speed block, we can control the number of times the motion has to be executed.

Testing Code


Click on the green flag to run the motion sequence.

Custome Speed Controls

We can also control the speed of the motion.

If you want to perform the motion at a different speed, then you can use a variable to define the speed.

Output


We can program a quadruped robot to move in predefined motions, such as forward, backward, left, and right

Code

Logic

  1. To initialize the quadruped extension, we need to set the pins for the FR Hip, FL Hip, FR Leg, FL Leg, BR Hip, BL Hip, BR Leg, and BL Leg blocks.
  2. To keep the program running infinitely, we can use the forever block.
  3. To execute predefined motions with specific speeds, we can use the do () motion () times at () speed block.
  4. To wait for a specific amount of time, we can use the wait () seconds block.

Output

Read More
In this tutorial, you'll discover how to use Python programming to control the Mars Rover. You'll learn how to use different keys on your keyboard to move the rover forward, backward, turn left, and turn right.

In this activity, we will make the computer program that controls the Mars Rover. It’s like a remote-control car. You can press different keys on the keyboard to make the Mars Rover move forward, backward, turn left and turn right.

Motor and Servo Motor

In our Mars rover, there are a total of 6 motors and 5 servo motors. 

The motors provide rotation to the wheels which helps the rover to attain motion in both forward and backward directions. All the left side motors (3 motors) are connected to the left motor port of Quarky and all the right side motors (3 motors) are connected to the right motor port of Quarky using a 3 port wire. This means that to control the Mars rover we have to control only 2 motors – Left and Right.

Also, there are 2 parameters to control – Direction (Forward or Backward) and Speed. With this control, the Mars rover can do all the desired motions.

The servo motors help in providing rotation to the complete wheel assembly so that the rover can change its wheel alignments and its path. These play a major role in turning cases of the Mars Rover.

We will need to turn the servo motors to the Inside Servo Position to make Mars Rover turn left and right.

Python Code

  1. We will make sure we have initialized Quarky and Mars Rover correctly.
  2. We will use the while loop to continuously detect the keys of the keyboard and react according to the way.
  3. We will use the python function of sprite “.iskeypressed()” to know which key has been pressed and act respectively.
  4. When the up arrow key is pressed, we will set all the servos to 90 degree angle with the help of the rover.home() function. We will run the mars rover with the help of quarky.runtimedrobot() function.
  5. With the same set of functions we will create the structure for when the users press the backward key to create the respective motion.
  6. When the user presses the right or left arrow key, we will set the servo angles to a specific degree – 40 to complete the turn successfully.
  7. By this way we will be able to turn the rover according to our needs by using the runtimedrobot()  function.
sprite=Sprite('Tobi')
import time
quarky = Quarky()
rover = MarsRover(4, 1, 7, 2, 6)
while True:
  if sprite.iskeypressed("up arrow"):
	  rover.home()
	  rover.setinangle(0)
	  quarky.runtimedrobot("F",100,3)
	
  if sprite.iskeypressed("down arrow"):
    rover.home()
    rover.setinangle(0)
    quarky.runtimedrobot("B",100,3)
  
  if sprite.iskeypressed("right arrow"):
    rover.home()
    rover.setinangle(40)
    quarky.runtimedrobot("R",100,3)
  
  if sprite.iskeypressed("left arrow"):
    rover.home()
    rover.setinangle(40)
    quarky.runtimedrobot("L",100,3)

Output

Forward-Backward Motions

Normal Right-Left Motions

Read More
Learn about humanoid robots, their form and functionality, and how the program uses arrow keys to control humanoid movement in different directions and speed.

Introduction

A humanoid is a type of robot or artificial system that is designed to resemble a human being in its form and functionality. Humanoid robots are typically equipped with sensors, actuators, and artificial intelligence capabilities that enable them to interact with their environment and perform tasks that are similar to those of a human being. Humanoid robots are used in various fields, including robotics research, entertainment, healthcare, education, and customer service.

Logic

The Humanoid will move according to the following logic:

  1. When the “UP” key is pressed – Humanoid will move forward.
  2. When the “Down” key is pressed – Humanoid will move Backward.
  3. When the “Left” key is pressed – Humanoid will turn left.
  4. When the “Right” key is pressed – Humanoid will turn Right.

Code

The program uses the up, down, left, and right arrows to control the robot and make it move forward, backward, left, and right. Every time you press one of the arrows, Humanoid will move in the direction you choose.

  1. First, we initialize the humanoid extension by dragging and dropping it onto the block we want to use for the humanoid.
  2. Then, we initialize the IF-ELSE block from the control palette.
  3. Here, we use the logic that if the up arrow key is pressed, the humanoid will move forward one step at a specific speed.
  4. If the down arrow key is pressed, the humanoid will move backward one step at a specific speed.
  5. When the right arrow key is pressed, the humanoid will move in the right direction one step at a specific speed using do() motion () times at () speed.
  6. If no key is pressed, the humanoid will return to its home position.

Output

Read More
Learn about humanoid robots, their form, functionality, and logic for movement. Explore the code that controls humanoid robots to move using arrow keys.

Introduction

A humanoid is a type of robot or artificial system that is designed to resemble a human being in its form and functionality. Humanoid robots are typically equipped with sensors, actuators, and artificial intelligence capabilities that enable them to interact with their environment and perform tasks that are similar to those of a human being. Humanoid robots are used in various fields, including robotics research, entertainment, healthcare, education, and customer service.

Logic

The Humanoid will move according to the following logic:

  1. When the “UP” key is pressed – Humanoid will move forward.
  2. When the “Down” key is pressed – Humanoid will move Backward.
  3. When the “Left” key is pressed – Humanoid will turn left.
  4. When the “Right” key is pressed – Humanoid will turn Right.

Code

The program uses the up, down, left, and right arrows to control the robot and make it move forward, backward, left, and right. Every time you press one of the arrows, Humanoid will move in the direction you choose.

sprite = Sprite('Tobi')
quarky = Quarky()
import time
humanoid = Humanoid(7, 2, 6, 3, 8, 1)
while True:
  if sprite.iskeypressed("up arrow"):
    humanoid.move("forward", 1000, 1)
    time.sleep(1)
    
  if sprite.iskeypressed("down arrow"):
    humanoid.move("backward", 1000, 1)
    
  if sprite.iskeypressed("left arrow"):
    humanoid.move("left", 1000, 1)
    
  if sprite.iskeypressed("right arrow"):
    humanoid.move("right", 1000, 1)

Explain the code

  1. The code defines a sprite named “Tobi” and creates an instance of a humanoid character named “quarky” using a Humanoid class.
  2. It then enters into an infinite loop that continuously checks if certain arrow keys are pressed using the sprite.iskeypressed() method.
  3. If the “up arrow” key is pressed, it calls the humanoid.move() method with parameters “forward”, 1000, and 1, which indicates that the humanoid should move forward at a speed of 1000 units with a duration of 1 second.
  4. If the “down arrow” key is pressed, it calls the humanoid.move() method with parameters “backward”, 1000, and 1, which indicates that the humanoid should move backward at a speed of 1000 units with a duration of 1 second.
  5. If the “left arrow” key is pressed, it calls the humanoid.move() method with parameters “left”, 1000, and 1, which indicates that the humanoid should move to the left at a speed of 1000 units with a duration of 1 second.
  6. If the “right arrow” key is pressed, it calls the humanoid.move() method with parameters “right”, 1000, and 1, which indicates that the humanoid should move to the right at a speed of 1000 units with a duration of 1 second.
  7. The code uses the time.sleep() function to pause for 1 second in each iteration of the loop, allowing for smoother movement of the humanoid.

Output

Read More
Learn to move your Quarky Mecanum Wheel Robot in a square and make an axe figure with PictoBlox. Use the arrow keys to activate the custom movements and watch your robot move in the desired direction!

In this activity, we will create a custom activity where you will be able to move the Mecanum robot in a square effortlessly along with making an Axe type figure.

The Quarky Mecanum Wheel Robot is a type of robot that uses a special type of wheel to move. The wheel is made of four rollers mounted at 45- degree angles to the wheel’s hub. Each roller has its own motor and can spin in either direction. This allows the wheel to move in any direction, making it an ideal choice for navigating around obstacles.

Coding Steps

Follow the steps:

  1. Open a new project in PictoBlox and select Block Coding Environment.
  2. Connect Quarky to PictoBlox.
  3. Click on the Add Extension button and add the Quarky Mecanum extension.
  4. Now we will first initialize the Mecanum robots and the servos before starting the main code.
  5. Here there are two parts specifically : To make a Square and To make an Axe

To make a Square (Logic):

The main steps would include to display the lights in arrow forms before implementing the specific move. The moves would be implemented in the following order:

Forward -> Lateral Right -> Backward -> Lateral Left.

We will display the arrows with the help of Quarky LED’s and implement the code.

Example of arrow:

Code for Square Motion:

To make an Axe (Logic):

The main steps would include to display the lights in arrow forms before implementing the specific move. The moves would be implemented in the following order:

Forward ( 2 steps ) -> Lateral Left ( 1 step ) -> Backward Right ( 1 step ) -> Backward ( 1 step )

We will display the arrows with the help of Quarky LED’s and implement the code.

Code for Axe Motion

Main Code

Now we will keep a specific condition on when to activate the Square Motion and when to activate the Axe Motion.

We will use the if-else conditions where on pressing the “up” arrow key, we will initiate the Square Motion and on pressing the “down” arrow key, we will initiate the Axe Motion with the help of Mecanum Robot.

Final Output

Square Motion:

Axe Motion:

Read More
Learn to move your Quarky Mecanum Wheel Robot in a square and make an axe figure with PictoBlox's Python Interface. Use the arrow keys to activate the custom movements!

In this activity, we will create a custom activity where you will be able to move the Mecanum robot in a square effortlessly along with making an Axe type figure.

The Quarky Mecanum Wheel Robot is a type of robot that uses a special type of wheel to move. The wheel is made of four rollers mounted at 45- degree angles to the wheel’s hub. Each roller has its own motor and can spin in either direction. This allows the wheel to move in any direction, making it an ideal choice for navigating around obstacles.

Coding Steps

Follow the steps:

  1. Open a new project in PictoBlox and select Python Coding Environment.
  2. Connect Quarky to PictoBlox.
  3. Click on the Add Extension button and add the Quarky Mecanum extension.
  4. Now we will first initialize the Mecanum robots and the servos before starting the main code.
  5. Here there are two parts specifically : To make a Square and To make an Axe

To make a Square (Logic):

The main steps would include to display the lights in arrow forms before implementing the specific move. The moves would be implemented in the following order:

Forward -> Lateral Right -> Backward -> Lateral Left.

Code for Square Motion:

def Square():
    quarky.drawpattern("jjjgjjjjjgggjjjgggggjjjjgjjjjjjgjjj")
    meca.runtimedrobot("forward",Speed,1)
    quarky.drawpattern("jjjjfjjjjjjffjfffffffjjjjffjjjjjfjj")
    meca.runtimedrobot("lateral right",Speed,1)
    quarky.drawpattern("jjjcjjjjjjcjjjjcccccjjjcccjjjjjcjjj")
    meca.runtimedrobot("backward",Speed,1)
    quarky.drawpattern("jjgjjjjjggjjjjgggggggjggjjjjjjgjjjj")
    meca.runtimedrobot("lateral left",Speed,1)
    quarky.drawpattern("ccccccccccccccccccccccccccccccccccc")
    time.sleep(1)
    quarky.cleardisplay()

To make an Axe (Logic):

The main steps would include to display the lights in arrow forms before implementing the specific move. The moves would be implemented in the following order:

Forward ( 2 steps ) -> Lateral Left ( 1 step ) -> Backward Right ( 1 step ) -> Backward ( 1 step )

We will display the arrows with the help of Quarky LED’s and implement the code.

Code for Axe Motion:

def Axe():
    quarky.drawpattern("jjjcjjjjjcccjjjcccccjjjjcjjjjjjcjjj")
    meca.runtimedrobot("forward",Speed,2)
    quarky.drawpattern("jjgjjjjjggjjjjgggggggjggjjjjjjgjjjj")
    meca.runtimedrobot("lateral left",Speed,1)
    quarky.drawpattern("jjhjjjjjjjhjjjjjjjhjhjjjjjhhjjjhhhh")
    meca.runtimedrobot("backward right",Speed,1)
    quarky.drawpattern("jjjdjjjjjjdjjjjdddddjjjdddjjjjjdjjj")
    meca.runtimedrobot("backward",Speed,1)
    quarky.drawpattern("ccccccccccccccccccccccccccccccccccc")
    time.sleep(1)
    quarky.cleardisplay()

Main Code

Now we will keep a specific condition on when to activate the Square Motion and when to activate the Axe Motion.

We will use the if-else conditions where on pressing the “up” arrow key, we will initiate the Square Motion and on pressing the “down” arrow key, we will initiate the Axe Motion with the help of Mecanum Robot.

sprite = Sprite('Tobi')
quarky=Quarky()
import time

def Square():
    quarky.drawpattern("jjjgjjjjjgggjjjgggggjjjjgjjjjjjgjjj")
    meca.runtimedrobot("forward",Speed,1)
    quarky.drawpattern("jjjjfjjjjjjffjfffffffjjjjffjjjjjfjj")
    meca.runtimedrobot("lateral right",Speed,1)
    quarky.drawpattern("jjjcjjjjjjcjjjjcccccjjjcccjjjjjcjjj")
    meca.runtimedrobot("backward",Speed,1)
    quarky.drawpattern("jjgjjjjjggjjjjgggggggjggjjjjjjgjjjj")
    meca.runtimedrobot("lateral left",Speed,1)
    quarky.drawpattern("ccccccccccccccccccccccccccccccccccc")
    time.sleep(1)
    quarky.cleardisplay()

def Axe():
    quarky.drawpattern("jjjcjjjjjcccjjjcccccjjjjcjjjjjjcjjj")
    meca.runtimedrobot("forward",Speed,2)
    quarky.drawpattern("jjgjjjjjggjjjjgggggggjggjjjjjjgjjjj")
    meca.runtimedrobot("lateral left",Speed,1)
    quarky.drawpattern("jjhjjjjjjjhjjjjjjjhjhjjjjjhhjjjhhhh")
    meca.runtimedrobot("backward right",Speed,1)
    quarky.drawpattern("jjjdjjjjjjdjjjjdddddjjjdddjjjjjdjjj")
    meca.runtimedrobot("backward",Speed,1)
    quarky.drawpattern("ccccccccccccccccccccccccccccccccccc")
    time.sleep(1)
    quarky.cleardisplay()


meca=Mecanum(1,2,7,8)


Speed = 100
quarky.drawpattern("jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj")
while True:
  if sprite.iskeypressed("up arrow"):
    Square()
  else:
    if sprite.iskeypressed("down arrow"):
      Axe()

Final Output

Square Motion:

Axe Motion:

Read More
Learn how to create a crawling motion with a quadruped robot using individual servo control.

Introduction

The project demonstrates how to make the crawling motion with Quadruped using individual servo control.

Logic

For this project, we are using the moveall(servo angles = [90,90,90,90,90,90,90,90], time = 1000) code that sets the servo motors of the quadruped to the specified angles at the specified speed.

quad.moveall([90,90,90,90,90,90,90,90],Speed)

There are four positions of the robot we are going to make to create the crawling motion:

  1. Position 1

    quad.moveall([60,120,0,180,60,120,180,0],Speed)

  2. Position 2

    quad.moveall([30,150,60,120,60,120,120,60],Speed)

  3. Position 3

    quad.moveall([120,60,60,120,120,60,120,60],Speed)

     

  4. Position 4

    quad.moveall([120,60,0,180,150,30,180,0],Speed)

     

Code

sprite = Sprite('Tobi')
quarky = Quarky()

quad=Quadruped(4,1,8,5,3,2,7,6)

Speed = 250
while True:
	quad.moveall([60,120,0,180,60,120,180,0],Speed)
	quad.moveall([30,150,60,120,60,120,120,60],Speed)
	quad.moveall([120,60,60,120,120,60,120,60],Speed)
	quad.moveall([120,60,0,180,150,30,180,0],Speed)

Logic

  1. The quadruped named quad is given a series of commands to move in different directions and patterns at a certain speed (Speed).
  2. The moveall method is used to move all of the legs of the quadruped in unison, and it takes a list of eight angles as its input argument.
  3. These angles correspond to the joints in the quadruped’s legs and dictate how they should move. The first four angles control the front left, front right, back left, and back right legs, respectively, and the second four angles control the same legs in the opposite order.
  4. First call to moveall moves the quadruped’s legs to make it walk forward, while the second call makes it turn to the left.
  5. The other calls make it perform other movements, such as turning to the right and walking backwards.

Output

Read More
Learn how to use PictoBlox to control the predefined motions of the Quadruped robot.

Introduction

In this project, we will explain how to run predefined motions in PictoBlox for the Quadruped. The predefined motions allow users to make the robot move forward, backward, left, right, and much more.

Code

sprite = Sprite('Tobi')
quirky = Quarky()
import time
quad=Quadruped(4,1,8,5,3,2,7,6)

while True:
  quad.home()
  time.sleep(0.5)
  quad.move("forward",1000,2)
  time.sleep(0.5)
  quad.move("backward",1000,2)
  time.sleep(0.5)
  quad.move("lateral left",1000,2)
  time.sleep(0.5)
  quad.move("lateral Right",1000,2)
  quad.home()

Logic

  1. First, import time imports the built-in time module, which provides functions for dealing with time.
  2. While True creates an infinite loop that will continue running until the program is interrupted.
  3. Then we call quad.home() is the home method of the Quadruped class, which resets the position of the quadruped object to its starting position.
  4. Now,time.sleep(0.5) causes the program to pause for 0.5 seconds before continuing to the next line of code.
  5. Then quad.move(“forward”,1000,2) causes the quadruped to move forward 1000 steps at a speed of 2 steps per second.
  6. Steps 7 and 8 are repeated for the “backward“, “lateral left“, and “lateral right” movements, each with a pause in between.
  7. Furthermore,home () is called again to return the quadruped to its starting position.
  8. Overall, We can program a quadruped robot to move in predefined motions, such as forward, backward, left, and right.

Output

Read More
The Language Translator with ChatGPT is a powerful system that enables real-time translation and conversation support, facilitating multilingual communication.

Introduction

The Language Translator with ChatGPT and Speech Recognition is a system that helps people communicate across languages by providing real-time translation and conversation support. It combines language translation, chatbot capabilities, and speech recognition to facilitate multilingual communication.

Language Translator Using ChatGPT is a project that trains the ChatGPT language model with multilingual data to enable it to understand and translate text between different languages. It utilizes ChatGPT’s natural language processing abilities to generate human-like responses, making it ideal for building a language translation system. The training data includes sentence pairs in different languages and their corresponding translations.

Logic

The code represents a conversation between the sprite character “Tobi” and the AI models. The sprite asks the user for a definition, the user responds, the AI generates a result based on the response, and the sprite says and speaks the result.

Follow the steps below:

  1. Open PictoBlox and create a new file.
  2. Choose a suitable coding environment for block-based coding.
  3. Add the extensions to your project from the extension palette located at the bottom right corner of PictoBlox.
  4. We create an instance of the Text to Speech class called speech. This class allows us to convert text into spoken audio.
  5. Next, we create an instance of the ChatGPT model called gpt. ChatGPT is a language model that can generate human-like text responses based on the input it receives. 
  6. The sprite asks the user to provide a sentence by using the input() function and stores the input in the variable ‘l‘.
  7. The translatelanguage() method of the ‘gpt‘ object is then used to translate the sentence stored in ‘l’ into Hindi. The translated sentence is stored in the variable ‘result‘.
  8. The sprite uses the say() method say() to speak out the translated sentence stored in ‘result’.
  9. The speak() method of the speech() object is called to convert the translated sentence into audio and play it.

Code

sprite = Sprite('Tobi')
gpt = ChatGPT()
speech = TexttoSpeech()

sprite.input("Provide a Sentece i will traslated into Hindi ")
l = str(sprite.answer())

gpt.translatelanguage(l,"hindi")
result=gpt.chatGPTresult()

sprite.say(result,2)
speech.speak(result)

Output

Read More
Discover the capabilities of pick-and-place robotic arms, mechanical systems designed to efficiently pick up objects from one location and precisely place them in another.

Introduction

A pick-and-place robotic arm is a mechanical system designed to perform the task of picking up objects from one location and placing them in another. It consists of multiple segments connected, similar to a human arm, and is equipped with motors, sensors, and grippers.

The robotic arm is programmed to move in a precise and controlled manner. It can be guided by various input methods, such as a computer interface or remote control. The arm uses its grippers to grasp objects securely, and then it can move them to a different location.

Pick-and-place robotic arms are commonly used in industries such as manufacturing, logistics, and assembly lines. They automate repetitive tasks that involve moving objects, saving time and reducing the risk of human error. These robotic arms can handle a wide range of objects, from small components to larger items, with accuracy and efficiency.

Code

Logic

  1. Open the Pictoblox application.
  2. Select the block-based environment.
  3. Click on the robotic arm extension available in the left corner.
  4. Drag and drop the Set Pins Link1(), Link2(), Base(), and Gripper() block to define the robotic arm for each servo connection.
  5. Use the Calibrate Link1(), Link2(), and Base() block to set the angle.
  6. Drag and drop the Set Offset Along Length() and Set Offset along Z() blocks to adjust the position of the end effector in the z-direction.
  7. Select the home() block to set the home position for the robotic arm.
  8. Open the gripper to pick up a specific object.
  9. Close the gripper to grab the object securely.
  10. Move to the desired location, then open the gripper to release the object.
  11. Close the gripper afterward.
  12. Then The arm will move to its default or home position using home() block.
  13. Press Run to run the code.

Output

Read More
Learn how to control a gripper using two different methods: 2-keycontrol, which activates when either the 'o' or 'c' key is pressed, and 1-key control, which activates when the 'space' bar is pressed.

Introduction

The gripper is used to pick and place any object. We are going to learn how to control it in this example.

The gripper has 2 states:

  1. Open – When the gripper servo motor angle is 0
  2. Close – When the gripper servo motor angle is 50

Control Logic

Now there are many methods to control the gripper. We will discuss 2 methods:

  1. 2 Key Control: In this method, the gripper will open when the “o” key is pressed and close when the “c” key is pressed.
  2. 1 Key Control: In this method, the gripper will open and close with only 1 key – “space”.

Let’s see how they work.

Setup PictoBlox

  1. Open the Pictoblox application.
  2. Select the Block Coding Environment.
  3. Click on the Robotic Arm extension available in the left corner.

2 Key Control

Logic

  1. The code checks if the “o” or “c” buttons are pressed with an if statement.
    1. If the “o” button is pressed, it will open the gripper.
    2. If the “c” button is pressed, it will close the gripper.
  2. The forever loop allows for the if statement to evaluate continuously.

Run the code to check the working of the gripper:

1 Key Control

Logic

  1. The code first sets the gripper to the “open” position.
  2. The code then enters an infinite loop, where it checks if the “space” button is pressed. If it is, it checks the current state of the gripper.
    1. If the gripper is in the “Open” state, it executes the “close” command and changes the state to “Close”. It then waits 0.2 seconds.
    2. If the gripper is in the “Close” state, it executes the “open” command and changes its state to “Open”. It also waits 0.2 seconds.

Conclusion

In this project, we learned how to control the gripper using two different methods. The first was 2-key control, which activated when either the ‘o’ or ‘c’ key was pressed. The second was 1-key control, which activated when the ‘space’ bar was pressed. Both were able to accurately open and close the gripper and can be used in robotics applications.

Read More
Explore the capabilities of a wirelessly controlled robotic arm, a mechanical system operated without physical connections.

Introduction

A wireless controlled robotic arm revolutionizes how we interact with robots by eliminating the need for physical connections. Users can remotely manipulate the arm’s movements without being tied to it, offering flexibility and convenience.

Wireless control allows operating the robotic arm from a distance, ensuring safety and versatility. It can be controlled through a smartphone app, remote control, or computer software. Wireless communication protocols like Bluetooth or Wi-Fi enable seamless transmission of commands.

These robotic arms have applications in industrial automation, healthcare, research, and education. They provide precise movements for delicate tasks and complex maneuvers, such as object manipulation, surgeries, or hazardous environment exploration.

Wireless control enables automation, remote operation, and collaboration. Multiple arms can be controlled simultaneously, enhancing productivity and enabling cooperative tasks. Integration with smart systems and the Internet of Things (IoT) ecosystem is facilitated.

Code

sprite = Sprite('Tobi')

import time

roboticArm = RoboticArm(1,2,3,4)


roboticArm.sethome()
roboticArm.setgripperangle(90,148)
while True:
	if sprite.iskeypressed("up arrow"):
		roboticArm.movebyinoneaxis(10,"X",10)
	
	if sprite.iskeypressed("down arrow"):
			roboticArm.movebyinoneaxis(-10,"X",1000)
			
	if sprite.iskeypressed("left arrow"):
	 roboticArm.movebyinoneaxis(10,"Y",1000)
			
	if sprite.iskeypressed("right arrow"):
		roboticArm.movebyinoneaxis(-10,"Y",1000)
		
	if sprite.iskeypressed("o"):
	 roboticArm.movebyinoneaxis(10,"Z",1000)
			
	if sprite.iskeypressed("c"):
		roboticArm.movebyinoneaxis(-10,"Z",1000)

Logic

User  control the robotic arm’s movements using arrow keys for X and Y axes and the ‘o‘ and ‘c‘ keys for the Z-axis. The specific movements and functions may vary depending on the implementation of the Roboti Arm class.

  1. Open the Pictoblox application.
  2. Select the Python-based environment.
  3. Click on the robotic arm extension available in the left corner.
  4. First initialize the robotic arm‘s pin with pictoblox.
  5. Imports the time module, which provides functions for time-related operations.
  6. Initializes a robotic arm object named ‘roboticArm‘ with four parameters.
  7. Sets the home position for the robotic arm. This is usually a predefined position that serves as a reference point.
  8. Sets the angle of the gripper of the robotic arm. This function likely controls the opening and closing of the gripper.
  9. Everything inside this loop will repeat indefinitely until the program is manually stopped.
  10. If the up arrow key is pressed, it moves the robotic arm by 10 units in the positive X-axis direction.
  11. If the down arrow key is pressed, it moves the robotic arm by 10 units in the negative X-axis direction.
  12. If the left arrow key is pressed, it moves the robotic arm by 10 units in the positive Y-axis direction.
  13. If the Right Arow key is pressed, it moves the robotic arm by 10 units in the negative Y-axis direction.
  14. The code repeats the same pattern for the other arrow keys (down, left, and right) and performs movements in the corresponding axis directions.
  15. If the ‘o‘ key is pressed, it moves the robotic arm by 10 units in the positive Z-axis direction.
  16. If the ‘c‘ key is pressed, it moves the robotic arm by 10 units in the negative Z-axis direction.
  17. Press Run to run the code.

Output

Read More
Discover the fascinating world of LCD (Liquid Crystal Display) technology. Learn how liquid crystals monitor light to create flat panel electronic visual displays without emitting light directly

Introduction

LCD(Liquid crystal display)

The liquid crystal display uses the property of light monitoring of liquid crystal and they do not emit the light directly. The Liquid crystal display is a flat panel display or the electronic visual display. With low information content the LCD’ s are obtained in the fixed image or the arbitrary image which are displayed or hidden like present words, digits, or 7 segment display. The arbitrary images are made up of large no of small pixels and the element has larger elements. A 16×2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in a 5×7 pixel matrix. The 16 x 2 intelligent alphanumeric dot matrix display is capable of displaying 224 different characters and symbols.

Circuit

Code

  • Create when flag clicked event
  • From display pallete,  drag initialize the 16×2 display and change the pin numbers as per the circuit diagram.
  • From control palette drag forever block
  • From display palette drag set cursor at column() row()
  • Again from display palette drag write() display enter a message that you want to display on lcd screen.
  • Repeat the above to block and change the  column 3 and row to 2
  • From control palette add wat() block and then from the display palette add clear display block
  • Insert the above set of blocks in forever block

Script:

Output

 

 

Read More
Learn how to use the Object Detection extension of PictoBlox's Machine Learning Environment to count specific targets in images by writing Block code.

Introduction

In this example project we are going to create a Machine Learning Model which can count number of nuts and bolts from the camera feed or images.

Object Detection in Machine Learning Environment

Object Detection is an extension of the ML environment that allows users to detect images and making bounding box into different classes. This feature is available only in the desktop version of PictoBlox for Windows, macOS, or Linux. As part of the Object Detection workflow, users can add classes, upload data, train the model, test the model, and export the model to the Block Coding Environment.

 Opening Image Detection Workflow

Alert: The Machine Learning Environment for model creation is available in the only desktop version of PictoBlox for Windows, macOS, or Linux. It is not available in Web, Android, and iOS versions.

 

Follow the steps below:

  1. Open PictoBlox and create a new file.
  2.  Select the Block Coding Environment.
  3. Select the “Open ML Environment” option under the “Files” tab to access the ML Environment.
  4. You’ll be greeted with the following screen.
    Click on “Create New Project”.
  5. A window will open. Type in a project name of your choice and select the “Object Detection” extension. Click the “Create Project” button to open the Object Detection window.

You shall see the Object Detection workflow. Your environment is all set.
   

Collecting and Uploading the Data

Uploading images from your device’s hard drive

  1. Now it’s time to upload the images which you downloaded from another source or captured from your camera. Click on the “Select from device” option from the Import Images block.
  2. Now click on the “Choose images from your computer” and go to the folder where you downloaded your images.
  3. Select all images which you want to upload then click on “open” option.
  4. Now page of PictoBlox looks like:

Making Bounding Box – Labelling Images

  1. Labeling is essential for Object Detection. Click on the “Bbox” tab to make the labels.

    Notes: Notice how the targets are marked with a bounding box. The labels appear in the “Label List” column on the right.

  2. To create the bounding box in the images, click on the “Create Box” button, to create a bounding box. After the box is drawn, go to the “Label List” column and click on the edit button, and type in a name for the object under the bounding box. This name will become a class. Once you’ve entered the name, click on the tick mark to label the object.
  3. File List: It shows the list of images available for labeling in the project.
  4. Label List: It shows the list of Labels created for the selected image.
  5. Class Info: It shows the summary of the classes with the total number of bounding boxes created for each class.
  6.   You can view all the images under the “Image” tab.

Training the Model

In Object Detection, the model must locate and identify all the targets in the given image. This makes Object Detection a complex task to execute. Hence, the hyperparameters work differently in the Object Detection Extension.

  1. Go to the “Train” tab. You should see the following screen:
  2. Click on the “Train New Model” button.
  3. Select all the classes, and click on “Generate Dataset”.
  4.  Once the dataset is generated, click “Next”. You shall see the training configurations.
  5. Specify your hyperparameters. If the numbers go out of range, PictoBlox will show a message.
  6. Click “Create”, It creates new model according to inserting value of hyperparameter.
  7. Click “Start Training”, If desired performance is reached, click on the “Stop” 
    1. Total Loss
    2. Regularization Loss
    3. Localization Loss
    4. Classification Loss
  8. After the training is completed, you’ll see four loss graphs: 
    Note: Training an Object Detection model is a time taking task. It might take a couple of hours to complete training

     

  9. You’ll be able to see the graphs under the “Graphs” panel. Click on the buttons to view the graph.

    1. Graph between “Total loss” and “Number of steps”
    2. Graph between “Regularization loss” and “Number of steps”.
    3. Graph between “Localization” and “Number of steps”.
    4. Graph between “Classification loss” and “Number of steps”.

Evaluating the Model

Now, let’s move to the “Evaluate” tab. You can view True Positives, False Negatives, and False Positives for each class here along with metrics like Precision and Recall.

Testing the Model

The model will be tested by uploading an Image from device:

 

Export in Block Coding

Click on the “PictoBlox” button, and PictoBlox will load your model into the Block Coding Environment if you have opened the ML Environment in the Block Coding.

 

 

Code

The idea is simple, we’ll add image samples in the “Backdrops” column. We’ll keep cycling through the backdrops and keep predicting the image on the stage.

  1. Add testing images in the backdrop and delete default backdrop.
  2. Now, come back to the coding tab and select the Tobi sprite.
  3. We’ll start by adding a when flag clicked block from the Events palette.
  4. Add () bounding box block from the Machine Learning palette. Select the “hide” option.
  5. Follow it up with a set detection threshold to () block from the Machine Learning palette and set the drop-down to 0.5.
  6. Add switch backdrop to () block from the Looks palette. Select any image.
  7. Add a forever block from the  Control palette
  8. Add analyse image from() block from the Machine Learning palette. Select the “stage” option.
  9. Add () bounding box block from the Machine Learning palette. Select the “show” option.
  10. Add two blocks of say () for () seconds from the Looks palette.
  11. Inside the say block add join () () block from operator palette.
  12. Inside the join block write statement at first empty place and at second empty place add get number of () detected? from the Machine Learning palette.
  13. Select the “Nut” option for first get number of () detected and for second choose “Bolt” option.
  14. Add the () bounding box block from the Looks palette. Select the “hide” option.
  15. Finally, add the next backdrop block from the Looks palette below the () bounding box block.

Final Result

 

 

 

Read More
Learn about the fundamental working principle of a potentiometer and its versatile applications as a variable resistor or voltage divider

Potentiometer and It’s working

A potentiometer is a crucial three-terminal resistor featuring a sliding or rotating contact that forms an adjustable voltage divider. When using only two terminals (one end and the wiper), it functions as a variable resistor or rheostat. The potentiometer’s three pins consist of two connected to the resistive element (blue and green) and one connected to the adjustable wiper (black). The potentiometer can serve as a rheostat to vary resistance or as a voltage divider. The position of the wiper determines the amount of resistance imposed on the circuit, as demonstrated in the figure below.

Circuit Diagram

Code

  1. From the event palette add when flag clicked event.
  2.  Add forever loop 
  3.  From looks palette add say block.
  4. Now add read analog pin A0 in this say block.

Script

Output

Read More
Discover the fundamentals of switches as electrical components that connect or disconnect conducting paths in circuits, enabling interruption or diversion of electric current.

introduction:

A switch is an essential electrical component that can disconnect or connect the conducting path in an electrical circuit, effectively interrupting or diverting the electric current. It plays a critical role in ON-OFF control for various applications across industries such as telecommunications, industrial control equipment, commercial devices, and home appliances.

Applications

The primary application of switches is to enable the ON-OFF control of circuits. They are widely used in industries including:

  1. Telecommunication: Switches play a key role in telecommunication equipment, allowing users to turn devices ON or OFF.
  2. Industry Control Equipment: Industrial machinery and equipment often rely on switches for circuit control and operation.
  3. Commercial Equipment: Switches are used in various commercial devices to facilitate user control and energy-saving features.
  4. Home Appliances: Household appliances such as fans, lights, and kitchen appliances utilize switches for convenient operation.


Circuit Diagram

Code

  1. Add the “when flag clicked” event from the event palette.
  2. Use the “go to x() y()” block from the motion palette and set the coordinates to 0,0..
  3. Introduce the “forever” block from the control palette.
  4. From control palette select if -else condition, use block read the state of digital pin 6 of Arduino.
  5. Add the “if – else” condition block from the control palette to read the state of digital pin 6 of Arduino.
  6. If the button is pressed (state of digital pin 6 is high), make Tobi jump by changing y() by 40 steps,  If the button is not pressed (state of digital pin 6 is low), make Tobi jump back to the original position by using the “go to x() y()” block and setting the coordinates to 0,0.
  7. Insert this section of code inside the “forever” block and merge all the parts.

Script

Output

Read More
Learn to Interface an ultrasonic sensor with Arduino, use ultrasonic sensor to measure distance and much more

Ultrasonic Sensor and It’s working

An ultrasonic sensor is an electronic device that measures the distance of a target object by emitting ultrasonic sound waves, and converts the reflected sound into an electrical signal.

How does it work?

Ultrasonic waves travel faster than the speed of audible sound (i.e. the sound that humans can hear). Ultrasonic sensors have two main components: the transmitter (which emits the sound using piezoelectric crystals) and the receiver (which encounters the sound after it has traveled to and from the target). It works by emitting a sound wave that travels through the air and bounces back to the sensor if it encounters an obstacle or object.

Circuit Diagram

Code

  1. From event  drag when flag clicked 
  2. From  control drag forever block.
  3. From  look  drag  say()
  4. From sensor pellet of Arduino drag get ultrasonic sensor distance trig() echo()

Script

Output

Read More
Learn about soil moisture sensors and how they work to measure the moisture level in the soil.
introduction

The soil moisture sensor is a valuable tool used to determine the moisture content in the soil, crucial for efficient gardening, farming, and agricultural practices. This analog sensor generates varying output values depending on the moisture level present in the soil. Typically, it operates as a two-pin circuit, with these pins responsible for powering up the sensor module. To obtain soil moisture readings, a voltage divider circuit is employed on the negative pin of the sensor, resulting in a signal pin that provides the moisture level data. Alternatively, some sensor modules come with a controller circuit that automatically converts the 2-pin connection into a 3-pin output, simplifying the process of accessing moisture values.

Below is a simple circuit diagram and code to get you started with monitoring soil moisture using an Arduino board. By following these steps, you can create your own moisture monitoring system with ease. Let’s begin!

 

Soil Moisture Sensor Hookup Guide - SparkFun LearnAuslese™ Detection Module Soil Moisture Sensor (Pack of 1Pcs) : Amazon.in: Industrial & Scientific

circuit diagram

Code

  1. Goto my variables and create a variable and name it “moisture level.” Set its initial value to 0.
  2. Add a “forever” loop from the control palette..
  3. Inside the forever loop, add a “set () to ()” block using the “my variable” category. Set the variable “moisture level” to the output value of the next block.
  4. From the Arduino palette, add the “map () from ()-() to ()-()” block. Replace the placeholder “0” with the map block.
  5. From the sensor palette, insert the “read analog sensor () at ()” block in place of “50”, and change the data range from 0-1023 to 0-100, also add “when flag clicked” at the start of the script, from event palette. As shown below.
  6. Add an “if-else” block from the controls palette. Use it to check whether the value of the sensor greater than 50% or not.
  7. If the value is greater than 50%, activate the buzzer connected to pin 13.
  8. And if the value if less then 50% then the buzzer must remain OFF.

Script

With these steps, your script is complete, and you can now monitor the soil moisture effectively using the soil moisture sensor and Arduino board. Happy gardening and farming!

Output

 

 

 

Read More
Learn about the components of the sensor module, including the IR LED and photodiode, and understand the circuit connections.
Introduction

he IR (Infrared) sensor, a remarkable obstacle detection sensor, relies on the fundamental principle of light reflection. Within its compact module, the IR LED emits infrared radiation forward into its environment. As these radiant waves encounter any object along their path, they bounce back toward the sensor module. The photodiode, often identified by its black color, plays a crucial role in detecting these reflected rays.

Circuit

connection

IR_VCC – 5v

IR_GND – GND

IR_OUTPUT – D7

LED+ to D9

LED- to  GND

Resistance -270

Code

create a circuit on the breadboard as per the above circuit diagram

  1. From control drag  if -else block.
  2. From the Arduino sensor palette, add a “read digital sensor () at ()” block. Choose “proximity” as the sensor type and select pin 7.
  3. The sensor’s detection of an object will alter the status of pin 7 from LOW to HIGH. In response to object detection, add the “set digital pin () output as ()” block from the Arduino palette within the “if” block.
  4. For the “else” part, ensure the LED turns off when no object is in front of the sensor.
  5. Drag a “forever” block from the controls palette and place the above set of blocks inside it.
  6. finally, add when flag clicked block from events palette

 

Script

Output

Read More
Line-following with Quarky's default IR sensors using PID control and adaptive feedback for smooth, precise path tracking. Ideal for advanced robotics learning!

Steps :

  1. Set IR threshold for stopping the robot at the crossing lines
  2. use a block to get the IR value for reading the IR value
  3. The below example uses a pid line following blocks
  4. First, click on the flag to initialize and set the pin for the line following
  5. When you click doline following robot start line following and stop at the Check-point (when both IRs are at the Black line)

Script

 

 

Read More
In this example, we will retrieve the information from the cloud and make the Quarky lights ON and OFF. 

In this example, we are going to understand how to make a feed on Adafruit IO. Later we will write the Python code that will retrieve the information from the cloud and make the Quarky lights ON and OFF.

Adafruit IO Key

You can find the information about your account once you log in from here:

Note: Make sure you are login on Adafruit IO: https://io.adafruit.com/

Creating a Light Switch in Adafruit IO

  1. Create a new Feed named Light.
  2. Create a new Dashboard named Light Control.
  3. Edit the Dashboard and add a Toggle Block.
  4. Connect the Light feed to the block and click on Next Step.
  5. Edit the Block Setting and click on Create Block.
  6. Block is added. You can try to toggle the switch.
  7. Go to the Light feed. You will observe the value of the feed changing as we click on the switch on the Dashboard.

Script

The following script reads the Light feed value and makes the Quarky light up accordingly.

Output

Script for Upload Mode

You can also make the script work independently of PictoBlox using the Upload Mode. For that switch to upload mode and replace the when green flag clicked block with when Quarky starts up block. Add the Wi-Fi connect blocks to connect Quarky to the Internet.

Download Code: https://pictoblox.page.link/HyUTYaW8VXX2XExK9

Troubleshooting:

  1. If the Green Light comes, your Wi-Fi is connected.
  2. If the Red Light comes, your Wi-Fi is not connected. Change the Wi-Fi and the password and try again.
  3. If the Red Cross sign comes, Quarky, Python error has occurred. Check the serial monitor and try to reset the Quarky.
Read More
In this tutorial, you will learn how to control a quadruped robot using the arrow key program.

Introduction

In this example, we will make the computer program that controls a “quadruped” (a four-legged robot). It’s like a remote control car, except with four legs instead of four wheels. You can press different keys on the keyboard to make the quadruped move forward, backward, turn left and turn right.

Logic

The Quadruped will move according to the following logic:

  1. 32Quadruped will move forward when the “UP” key is pressed.
  2. Quadruped will move backward when the “DOWN” key is pressed.
  3. Quadruped will turn left when the “LEFT” key is pressed.
  4. When the “RIGHT” key is pressed – Quadruped will turn right.

Code

The program uses the up, down, left, and right arrows to control the robot and make it move forward, backward, left, and right. Every time you press one of the arrows, Quarky will move in the direction you choose for 1000 steps.

Output

Read More
Learn how to connect a DHT sensor to PictoBlox and use the Adafruit IO cloud service to send temperature and humidity data to the cloud. Create a dashboard to visualize the temperature and humidity data with the help of line chart and gauge elements.

We will use the Adafruit IO cloud service to send data from a humidity and temperature sensor to the cloud in the Python Coding Environment of PictoBlox. Adafruit IO is a cloud service that allows you to send data from sensors and other devices to the cloud, where it can be stored and analyzed.

Adafruit IO Key

You can find the information about your account once you log in from here:

Note: Make sure you are login on Adafruit IO: https://io.adafruit.com/

DHT Sensor Connection to Quarky

DHT sensors have 3 pins: GND, VCC, and Signal. You have to connect the following 3 pins to the Quarky Expansion Board:

  1. GND to Ground Pin of Quarky Expansion Board
  2. VCC to 3.3V or VCC Pin of Quarky Expansion Board
  3. Signal to the D3 (Digital Pin) of the Quarky Expansion Board

Code for Stage Mode

# This code is used to connect to the internet and measure the temperature and humidity of the house.
# First, the Quarky object  are created.
quarky = Quarky()

# Time module is imported.
import time

# AdaIO object is created.
adaio = AdaIO()

# IoTHouse object is created.
house = IoTHouse()

# Then, the connection to Adafruit IO is made.
adaio.connecttoadafruitio("STEMNerd", "aio_UZBB56f7VTIDWyIyHX1BCEO1kWEd")

# The feeds for temperature and humidity are created.
adaio.createfeed("Temperature")
adaio.createfeed("Humidity")

# A while loop is used to measure the temperature and humidity continously.
while True:
  # Temperature is measured using the dhtmeasure function.
  adaio.createdata("Temperature", house.dhtmeasure(1, "D3"))
  # The loop pauses for 1 second.
  time.sleep(1)

  # Humidity is measured using the dhtmeasure function.
  adaio.createdata("Humidity", house.dhtmeasure(2, "D3"))
  # The loop pauses for 5 seconds.
  time.sleep(5)

 

The following feeds are created:

Creating Dashboard

Follow the steps:

  1. Go to the dashboard and click on New Dashboard.
  2. Add the Dashboard Name and Description and click on Create.
  3. Open the New Dashboard. Click on the Setting icon in the top right corner and then click on Create New Block.
  4. From the options, click on the line chart.
  5. Select the Temperature Feed and click on Next Step.
  6. Add the Block Title and the Y-Axis Minimum – Maximum value. Click on Create Block.
  7. You will find the block added on the dashboard.
  8. Add a Humidity block as well. Also, add two gauge elements showing the current temperature and humidity value.
  9. Click on the Setting button and Edit Layout to align all the buttons.
Read More
Learn how to control the Mars Rover using PictoBlox with motors and servo motors. Make the Mars Rover move forward, backward, turn left, and turn right.

In this activity, we will make the computer program that controls the Mars Rover. It’s like a remote-control car. You can press different keys on the keyboard to make the Mars Rover move forward, backward, turn left and turn right.

Motor and Servo Motor

In our Mars rover, there are a total of 6 motors and 5 servo motors. 

The motors provide rotation to the wheels which helps the rover to attain motion in both forward and backward directions. All the left side motors (3 motors) are connected to the left motor port of Quarky and all the right side motors (3 motors) are connected to the right motor port of Quarky using a 3 port wire. This means that to control the Mars rover we have to control only 2 motors – Left and Right.

Also, there are 2 parameters to control – Direction (Forward or Backward) and Speed. With this control, the Mars rover can do all the desired motions.

The servo motors help in providing rotation to the complete wheel assembly so that the rover can change its wheel alignments and its path. These play a major role in turning cases of the Mars Rover.

We will need to turn the servo motors to the Inside Servo Position to make Mars Rover turn left and right.

Coding Steps

Follow the steps:

  1. Open a new project in PictoBlox.
  2. Connect Quarky to PictoBlox.
  3. Click on the Add Extension button and add the Quarky Mars Rover extension.
  4. For optimizing the Mars Rover motion, we will use the servo motors attached to the Rocker Bogie mechanism. This will work in the following way:
    1. Straight Servo Position the Mars Rover to move in a forward or backward motion.
    2. Inside Servo Position the Mars Rover to turn left and right.To control this position, you have set () to () block in the Mars Rover extension. Using this block, we can achieve this orientation.
  5. We will use the go () at () % speed block from the Robot palette to control the motion of the Mars Rover. And stop motor from the Robot palette to stop the Mars Rover.
  6. Create the following code. The code defines the Robot orientation with Robot Straight and Robot Turn custom blocks. In the loop, the code checks if any of the arrow keys are pressed and performs the corresponding action. If no arrow keys are pressed, the robot stops.
  7. Click on the green flag to run the robot with keys.

Output

Forward-Backward Motions

Normal Right-Left Motions

Conclusion

Our mission is accomplished! With the coding steps above, we were able to successfully control the Mars Rover using the Quarky extension when connected to PictoBlox. We set the motors and servo motors of the Mars Rover and used the set () to () and go () at () % speed blocks. Additionally, we created custom blocks for robot straight and robot turn orientation to get the desired forward and backward movements and right and left turns. This control will help the Mars Rover to achieve its desired tasks!

Read More
Learn how to code the Mars Rover to turn left and right on a circle with the set () to () block. Try different left and right orientations and move the Mars Rover with the up and down keys.

Introduction

Instead of rotating the Mars Rover at a place to turn left or right, you can alternatives make the Mars Rover move in a circle.

  1. Turning left on a circle:
  2. Turning right on a circle:
  3. Turning right backwards in a circle:
  4. Turning left backwards in a circle:

Coding Steps

The following code uses the four arrow keys to travel forward (up arrow key), backwards (down arrow key) , forward right in a circle( right arrow key) and forward left in a circle. (left arrow key)

We will also use the keys specially for backward left and right motion. We will use the “a”  key for backward left motion and “d” key for backward right motion.

Make the code and play with the Mars Rover. Try to use different keys and combine different motions.

Code

sprite=Sprite('Tobi')
import time
quarky = Quarky()
rover = MarsRover(4, 1, 7, 2, 6)
# setwheelsangle(Front Left = 40, Front Right = 40, Back Left = 90, Back Right = 90)
while True:
  if sprite.iskeypressed("up arrow"):
	  rover.home()
	  rover.setinangle(0)
	  quarky.runtimedrobot("F",100,2)
	
  if sprite.iskeypressed("down arrow"):
    rover.home()
    rover.setinangle(0)
    quarky.runtimedrobot("B",100,2)
  
  if sprite.iskeypressed("right arrow"):
    rover.home()
    rover.setrightturnangle(40)
    # rover.setwheelsangle(180,180,180,180)
    # rover.setheadangle(0)
    quarky.runtimedrobot("F",100,2)
  
  if sprite.iskeypressed("left arrow"):
    rover.home()
    rover.setleftturnangle(40)
    # rover.setwheelsangle(0,0,0,0)
    quarky.runtimedrobot("F",100,2)
  
  if sprite.iskeypressed("A"):
    rover.home()
    rover.setleftturnangle(40)
    quarky.runtimedrobot("B",100,2)
  
  if sprite.iskeypressed("D"):
    rover.home()
    rover.setrightturnangle(40)
    quarky.runtimedrobot("B",100,2)

Output

Circular Right-Left Motion:

Read More
Learn how to code logic for video input detection with this example code. You will be able to direct your own Mars Rover easily by just showing signs through the camera input.

Introduction

A sign detector Mars Rover robot is a robot that can recognize and interpret certain signs or signals, such as hand gestures or verbal commands, given by a human. The robot uses sensors, cameras, and machine learning algorithms to detect and understand the sign, and then performs a corresponding action based on the signal detected.

These robots are often used in manufacturing, healthcare, and customer service industries to assist with tasks that require human-like interaction and decision making.

Code

sprite = Sprite('Tobi')
# sprite = Sprite('Tobi')
quarky = Quarky()
import time

recocards = RecognitionCards()
rover = MarsRover(4, 1, 7, 2, 6)

recocards.video("on flipped")
recocards.enablebox()
recocards.setthreshold(0.6)

while True:
  recocards.analysecamera()
  sign = recocards.classname()
  sprite.say(sign + ' detected')
  
  if recocards.count() > 1:
    if 'Go' in sign:
      rover.home()
      rover.setinangle(0)
      quarky.runtimedrobot("F",100,3)
      
    if 'Turn Left' in sign:
      rover.home()
      rover.setinangle(40)
      quarky.runtimedrobot("L",100,3)

    if 'Turn Right' in sign:
      rover.home()
      rover.setinangle(40)
      quarky.runtimedrobot("R",100,3)
      
    if 'U Turn' in sign:
      rover.home()
      rover.setinangle(0)
      quarky.runtimedrobot("B",100,3)

Logic

  1. Firstly, the code sets up the stage camera to look for signs and detects and recognizes the signs showed on the camera.
  2. Next, the code starts a loop where the stage camera continuously checks for the signs.
  3. Finally, if the robot sees certain signs (like ‘Go’, ‘Turn Left’, ‘Turn Right’, or ‘U Turn’), it moves in a certain direction (forward, backward, left, or backward) based on the respective signs.
  4. This can help the Mars Rover to manoeuvre through the terrain easily by just showing signs on the camera.

Output

Forward-Backward Motions:

Right-Left Motions:

Read More
Learn how to code logic for video input detection with this example block code. You will be able to direct your own Mars Rover easily by just showing signs through the camera input.

Introduction

A sign detector Mars Rover robot is a robot that can recognize and interpret certain signs or signals, such as hand gestures or verbal commands, given by a human. The robot uses sensors, cameras, and machine learning algorithms to detect and understand the sign, and then performs a corresponding action based on the signal detected.

These robots are often used in manufacturing, healthcare, and customer service industries to assist with tasks that require human-like interaction and decision making.

Code

Initializing the Functions:

Main Code

Logic

  1. Firstly, the code sets up the stage camera to look for signs and detects and recognizes the signs showed on the camera.
  2. Next, the code starts a loop where the stage camera continuously checks for the signs.
  3. Finally, if the robot sees certain signs (like ‘Go’, ‘Turn Left’, ‘Turn Right’, or ‘U Turn’), it moves in a certain direction (forward, backward, left, or backward) based on the respective signs.
  4. This can help the Mars Rover to manoeuvre through the terrain easily by just showing signs on the camera.

Output

Forward-Backward Motions:

Right-Left Motions:

Read More
All articles loaded
No more articles to load
[PictoBloxExtension]