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
  • Function without output
  • Function with outputs
  • Check condition
  • Call function
  1. Blockly Elements
  2. Advanced Blocks

Functions

Last updated 1 year ago

The functions folder contains all the blocks you need to create functions. Functions are a fundamental concept in programming that allow you to group blocks and code together to execute it as a single unit. They are like reusable blocks of code that can be called from different parts of your program, making your code more modular and easier to manage.

Functions are a powerful tool for writing structured, maintainable, and reusable code in Blockly. By mastering the use of functions, you can significantly improve the quality and efficiency of your programs.

Function without output

This block represents a function without an input. Its built out of different parts:

  • In the image, the "do something" is the name of the functions that will be recalled in the code. It's important to use different names for the functions.

  • By clicking on the question mark you can add a description of the function, this can be useful when you need to debug your code or explain to other programmers what your code is doing in that part.

  • By clicking on the gear you can choose which input to insert into your function.

  • The part inside the block, between the connect and the socket will contain all the sequences that the function will need to perform.

Function with outputs

This blocks is virtually identical to the previous block described but it returns an output that you've chosen. Instead, when statements are not allowed this function "closes" the gap and when it's called it will return what you add to the return socket.

Check condition

Note: This block can only be used in a function.

With this block, you can check a condition. If the value put in the 'if' socket is true then it will return the value in the 'return' socket. If the value is not true the function will end the program.

Call function

In order to call a function you must create a do something block and give it the same name as the function you want to call.

🅰️
function blocks
function without output block
function with outputs block
check condition block
call function block