Misty Lessons
  • Misty Lessons
    • 📖Welcome to Misty Lessons
    • 📚Get to know your Misty
    • 📲Connect to Misty
    • 👩‍💻Misty Studio
    • 🖥️Desktop Environment
    • ⬆️Update your Misty
    • 👥Projects
  • Blockly
    • 🧩Blockly Lessons
      • 🤸Lesson 1: Movement
      • 🎶Lesson 2: Voice and Sound
      • 🎭Lesson 3: Expressions
      • 🎥Lesson 4: Robot Cinema
      • 🛠️Lesson 5: Events
      • ☺️Lesson 6: Face recognition
      • 🔢Lesson 7: Variables and Functions
      • 💬Lesson 8: NLP
    • 🏫Blockly projects
  • Blockly Elements
    • ⚛️Misty Blocks
      • Movement
      • Speech
      • Audio
      • Vision
      • Events
      • Miscellaneous
      • NLP
      • System
    • 🔁Basic Blocks
      • Logic
      • Loops
      • Math
      • Text
      • Lists
    • 🅰️Advanced Blocks
      • Variables
      • Functions
  • Python
    • 🐍Python Lessons
      • 🦿Lesson 1: Loco-motion
      • 🤖Lesson 2 : Build a character
      • 🧠Lesson 3: Create memories
      • ⚒️Lesson 4: Event skills
      • 👀Lesson 5: Expand awareness
      • 🔗Lesson 6: Compact code
      • 🗣️Lesson 7: Start a conversation
  • Python Elements
    • 🐸Misty Python API
      • Motion and Mobility
      • Display and LED
      • Record Assets
      • Change/Remove Assets
      • Stream Assets
      • Get Assets
      • Events
      • Sensor Events
      • Speech and NLP
      • Arduino Backpack
      • System
      • Slam
    • 📗Python Definitions
  • Python Projects
    • 🔮MistyGPT
    • 🚨Misty Intruder Alert
    • 📺Conference Assistant
    • 🏷️QR code detector
    • 🕵️‍♂️Misty follow human
    • 👋Misty wave back
    • 🖲️Misty OA
    • 🌐Get weather
    • 🚚Misty Delivery
    • 🫂Motivational Misty
    • 🖼️Misty Museum Guide
    • 🎃Who for Halloween
  • ARDUINO
    • ♾️Arduino Backpack
    • 🦎Arduino
    • 🔧Arduino Lessons
      • 🔌Arduino to Misty
      • ➕Misty to Arduino
  • ARDUINO PROJECTS
    • 🛠️Misty Tracker
    • 🦾Misty Arm
  • Community Projects
    • 🌤️Misty weather forecaster
  • HARDWARE EXTENSION
    • ⚙️Arduino breadboard support
    • 🦾Misty arm
    • 🥤Tin holder
  • Resource Database
    • 📁Image files
    • 📁Audio files
    • 📁Languages
    • 📁Known objects
    • 📁NLP Actions
    • 📁Action Commands
    • 📁ChatGPT PDF files
    • 📁AR Tag Dictionary
    • ⚙️Technical Specifications
Powered by GitBook
On this page
  1. Python Projects

QR code detector

With this feature it's possible for Misty to detect and read QR codes. These can be used to tag spaces, for example: labs, classrooms, kitchens or living rooms to make Misty start actions.

Last updated 8 months ago

We suggest to use a printed QR code, about 15x15 cm. The QR code that we used for this project is the Misty Lessons one.

This project will only work in the Misty Desktop Environment because we will modify the events file.

Open the folder containing the Python-SDK that you use for the . The folder should look like this one.

Now you're ready to use Misty's scanning QR capabilities in Python.

Python Code

from mistyPy.Robot import Robot
from mistyPy.Events import Events

misty = Robot("YOUR_ROBOT_IP_ADDRESS") #your Robot IP Address

misty.change_led(0, 255, 0)
misty.move_head(0, 0, 0)

misty.start_qr_tag_detector()

def code(data):
    print(data) #this shows all the data related to the event
    print(data['message']['decodedInfo'])

misty.register_event(event_name='qrtag_event', event_type=Events.QrTagDetection, callback_function=code, keep_alive=True, debounce = 500)

misty.keep_alive()

In the first part of the code, we set the robot by initializing the libraries, calling it and setting it in a standard position. Once these actions are done we start the event like any other event in the Misty world by calling the action .start_qr_tag_detector().

We create a function that will handle the data read by scanning the QR code. We can then register the event and then keep it alive.

You can insert if statements to handle different QR codes and assign to each a different Misty action.

For example, if we want Misty to turn her RGB LED purple when she recognizes the QR code of the Misty lessons or have the RGB LED red when she doesn't, our function can look like this one:

def code(data):
    print(data['message']['decodedInfo'])
    if data['message']['decodedInfo'] == 'unknown person': #intruder
        misty.change_led(100, 70, 160)
    else :
        misty.change_led(255, 0, 0)

Open the folder MistyPy, open the file in Visual Studio code and modify the Events class to add the QRdetection Event.

🏷️
Events.py
desktop environment