Sensors (Quarky)

Quaky-sensors
Extension Description
Get the sensor input from the button, infrared sensors, touch sensors, ultrasonic sensors, and other sensors.

Introduction

The Sensor extension allows the users to read and interact with the various sensors of the Quarky robot.

Connecting Quarky with PictoBlox

Let’s begin by first connecting Quarky to PictoBlox. Select your preferred type of device i.e. either the desktop/laptop or your smartphone and follow the instructions.

Desktop

Follow the steps below for connecting Quarky to PictoBlox:

  1. First, connect Quarky to your laptop using a USB cable.
    Power Quarky
  2. Next, open PictoBlox on your desktop.
  3. After that, select Block or Python Coding as your coding environment.
  4. Then, click the Board button in the toolbar and select board as Quarky.
  5. Next, select the appropriate Serial port if the Quarky is connected via USB or the Bluetooth Port if you want to connect Quarky via Bluetooth and press Connect.
    COM Port

And voila! Quarky is now connected to PictoBlox.

Mobile

Follow the steps below for connecting Quarky to PictoBlox:

  1. First, power ON Quarky.
  2. Open PictoBlox on your smartphone. Go to My Space and make a new project by clicking the ‘+(plus)’ button in the bottom-right corner.
    PictoBlox in Mobile Phone
  3. Then, tap the Board button in the top-right corner of the toolbar.
    PictoBlox BoardSelect board as Quarky.
  4. Next, tap the Connect button:
    PictoBlox ConnectSelect your device from the list.

And voila! Quarky is now connected to PictoBlox.

Stage Mode

Stage mode is one of the two modes you can write your programs in Pictoblox. In this mode, you can write scripts for the sprite and boards to interact with sprites in real-time. If you disconnect the board with Pictoblox, you cannot interact with the board anymore. In this mode, you can make games and animation interacting with Quarky.

You can toggle between the upload mode and stage mode using the button on the top right side of Pictoblox.

Note:  You have to upload the firmware into the device before interacting with it. Please refer to this doc: https://ai.thestempedia.com/docs/updating-quarky-firmaware-with-pictoblox/

In Python Coding Environment, use the following object declaration to use Python functions in Stage Mode:

quarky = Quarky()

Upload Mode

Upload mode is one of the two modes you can write your programs in Pictoblox. This mode allows you to write scripts and upload them to the board so that you can use them even when it is not connected to your computer, for example, you need to upload a script for making moving robots.

In this case, Quarky will run offline according to the program and it can not interact with the stage.

In Python Coding Environment, use the following object declaration to use Python functions in Upload Mode:

from quarky import *
Read More

PictoBlox Blocks

The block is a hat block and starts the execution of the script added under it when the specified push button is pressed. 
The block returns the state of the specified push button. If the button is pressed it returns True or else False.
The block returns the state of the specified IR sensor. It returns True if the current IR sensor value is greater than the threshold value, else False.
The block returns the IR sensor analog reading. The reading varies from 0 to 4095.
The block sets the threshold value of the specified IR sensor to the specified value. The value can be from 0 to 4095.
The block is a hat block and starts the execution of the script added under it when the specified touch sensor of Quarky is pressed.
The block returns the state of the specified touch sensor of Quarky. If the touchpad is touched it will return True, else False.
The block initializes the ultrasonic sensor with specified echo and trig pins.
The block returns the distance reading from the specified ultrasonic sensor.
The block returns the analog reading of the sensor connected to the specified analog pin of the Quarky. The value varies between 0 to 4095.
The block returns the state of the digital sensor connected to the specified pin of the Quarky.
All articles loaded
No more articles to load

Block Coding Examples

All articles loaded
No more articles to load

Python Functions

The function returns the state of the specified push button. If the button is pressed it returns True or else False.
Syntax: readpushbutton(button = “L”)
The function returns the IR sensor analog reading. The reading varies from 0 to 4095.
Syntax: readirsensor(sensor = “IRL”)
The function sets the threshold value of the specified IR sensor to the specified value. The value can be from 0 to 4095.
Syntax: setirthreshold(sensor = “IRL”, value = 1200)
The function returns the state of the specified IR sensor. It returns True if the current IR sensor value is greater than the threshold value, else False.
Syntax: getirstate(sensor = “IRL”)
The function returns the state of the specified touch sensor of Quarky. If the touchpad is touched it will return True, else False.
Syntax: ispadtouched(touch_pin = 1)
The function initializes the ultrasonic sensor with specified echo and trig pins. 
Syntax: setultrasonicpins(sensor_number = 1, trig_pin = “D1”, echo_pin = “D2”)
The function returns the distance reading from the specified ultrasonic sensor.
Syntax: getdistance(sensor_number = 1)
The function returns the state of the digital sensor connected to the specified pin of the Quarky.
Syntax: readdigitalsensor(digital_pin = “D1”)
The function returns the analog reading of the sensor connected to the specified analog pin of the Quarky. The value varies between 0 to 4095.
Syntax: readanalogsensor(analog_pin = “A1”)
All articles loaded
No more articles to load

Python Coding Examples

All articles loaded
No more articles to load
Table of Contents