Table of Contents

drawpattern()

Function Definition: drawpattern(pattern = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")

Parameters

NameTypeDescriptionExpected ValuesDefault Value
patternstringthe 35 char string where each char corresponds to a color in the color palette.String"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

Description

The function sets the RGB LED matrix to the pattern specified in Pictoblox. The parameter passed is a 35 char string where each char corresponds to a color in the color palette.

Example

Beating-Heart (4)
The project shows how to create custom patterns on Quarky RGB LED in Stage Mode.

Beating-Heart (4)

Code

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

import time

while True:
	quarky.drawpattern("jjbjbjjjbbbbbjjbbbbbjjjbbbjjjjjbjjj")
	time.sleep(0.4)
	quarky.drawpattern("jjjjjjjjjbjbjjjjbbbjjjjjbjjjjjjjjjj")
	time.sleep(0.4)
Read More
The project shows how to create custom patterns on Quarky RGB LED in Upload Mode.

Beating-Heart (4)

Code

from quarky import *
import time

while True:
	quarky.drawpattern("jjbjbjjjbbbbbjjbbbbbjjjbbbjjjjjbjjj")
	time.sleep(1)
	quarky.drawpattern("jjjjjjjjjbjbjjjjbbbjjjjjbjjjjjjjjjj")
	time.sleep(1)
Read More
The example displays how we can display a custom pattern on the matrix by making a script to display a Traffic Light in the Python Coding Environment.

Code

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

import time

quarky.setbrightness(15)

while True:
	quarky.drawpattern("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
	time.sleep(5)
	quarky.showtext("2", [255,233,0])
	time.sleep(1)
	quarky.showtext("1", [255,233,0])
	time.sleep(1)
	quarky.drawpattern("ccccccccccccccccccccccccccccccccccc")
	time.sleep(5)
	quarky.showtext("2", [255,233,0])
	time.sleep(1)
	quarky.showtext("1", [255,233,0])
	time.sleep(1)

Output

Read More
The example demonstrates using the Quarky touch display to make a touch piano in the Python Coding Mode.

Code

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

while True:
  if quarky.ispadtouched("T1"):
    quarky.drawpattern("bbbjjbjjbjjbbjjbjjjbjjbjjjbjjbjjbbb")
    quarky.playtone("C4", 8)

  if quarky.ispadtouched("T2"):
    quarky.drawpattern("cccjcccjcjjjjcjcjjcccjcjjcjjjcjjccc")
    quarky.playtone("D4", 8)

  if quarky.ispadtouched("T3"):
    quarky.drawpattern("fffjfffjfjjjjfjfjjfffjfjjjjfjfjjfff")
    quarky.playtone("E4", 8)

  if quarky.ispadtouched("T4"):
    quarky.drawpattern("dddjdjdjdjjdjdjdjjdddjdjjjjdjdjjjjd")
    quarky.playtone("F4", 8)

  if quarky.ispadtouched("T5"):
    quarky.drawpattern("gggjgggjgjjgjjjgjjgggjgjjjjgjgjjggg")
    quarky.playtone("G4", 8)

Output

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 set the bounding box threshold, and detect signals such as 'Go', 'TurnRight', 'TurnLeft', and 'Stop' to control quadruped movements.

Introduction

Sign detection is being performed using a camera and a RecognitionCards object. The RecognitionCards object is set up with a threshold value and is enabled to draw a box around the detected object. 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')
quarky = Quarky()

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

recocards = RecognitionCards()
recocards.video("on flipped")
recocards.enablebox()
recocards.setthreshold(0.6)
quad.home()
while True:
  recocards.analysecamera()
  sign = recocards.classname()
  sprite.say(sign + ' detected')
  
  if recocards.count() > 0:
    if 'Go' in sign:
      quarky.drawpattern("jjjijjjjjiiijjjiiiiijjjjijjjjjjijjj")
      quad.move("forward",1000,1)
      
      
    if 'Turn Left' in sign:
      quarky.drawpattern("jjjddjjjjjdddjdddddddjjjdddjjjjddjj")
      quad.move("lateral right",1000,1)
      
      
    if 'Turn Right' in sign:
      quarky.drawpattern("jjggjjjjgggjjjgggggggjgggjjjjjggjjj")
      quad.move("lateral left",1000,1)
      
      
    if 'U Turn' in sign:
      quarky.drawpattern("jjjbjjjjjjbjjjjbbbbbjjjbbbjjjjjbjjj")
      quad.move("backward",1000,1)
      
      
    else:
      quad.home()

Logic

  1. This code is using several objects to detect and respond to certain signs or images captured by a camera.
  2. First, it creates a Sprite object with the name ‘Tobi’, and a Quarky object. It also imports a time module.
  3. Next, a Quadruped object is created with some parameters. Then, a RecognitionCards object is created to analyze the camera input. The object is set to enable a box around the detected object and to set the threshold of detection to 0.6.
  4. The code then puts the Quadruped object in its home position and enters an infinite loop.
  5. Within the loop, the code captures the camera input and uses the RecognitionCards object to analyze it. If an object is detected, the object’s class name is retrieved and used by the Sprite object to say that the object was detected.
  6. If the count of detected objects is greater than zero, the code checks if the detected object is a specific sign.
  7. If the object is a ‘Go‘ sign, the Quarky object will draw a specific pattern, and the Quadruped object will move forward.
  8. If the object is a ‘Turn Left‘ sign, the Quarky object will draw a different pattern and the Quadruped object will move to the right.
  9. If the object is a ‘Turn Right‘ sign, the Quarky object will draw another pattern, and the Quadruped object will move to the left.
  10. Finally, if the object is a ‘U Turn‘ sign, the Quarky object will draw a fourth pattern, and the Quadruped object will move backward.
  11. If the detected object is not any of the specific signs, the Quadruped object will return to its home position.
  12. So, this code helps a robot understand hand signs and move in response to them!

Output

Read More
All articles loaded
No more articles to load