Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Simple BlocklyProp Programs for Propeller Boards

Simple BlocklyProp Programs for Propeller Boards

Making Decisions

After you’ve learned the basics of programming, you will begin connecting inputs, such as buttons or sensors, and outputs, such as screens and lights, to your Propeller Activity Board WX.  You may want to write a program that makes a decision. For instance, you may want your program to turn on a light when you press a button.

In this program, you will use the Terminal receive text block located under COMMUNICATE > TERMINAL and the length of string block from OPERATORS > STRINGS to make a program that decides if an individual’s first name is shorter or longer than 7 letters.

 

Test Code

  • Open a new BlocklyProp Project.
  • Build the following program:

  • Select your board’s COM port from the device menu drop-down.
  • Click “Run once (load code to RAM)”
  • After your program loads, the Terminal will display:

  • Click in the Terminal, type your name, and press the enter/return key when you are finished. 

You will not be able to use the delete/backspace key, so if you make a mistake, just reload your program and start over. Now, your program will display how many letters long the name is that you entered.

 

Pro Tip: Use Spaces!

Use spaces when typing text in your block to help make your program more readable in the Terminal.  If you don’t add spaces to text that appears before and after a number that you are trying to print in the middle of a statement, it will look like this:

By adding spaces, the output is easier to read:  

These extra spaces will print this in the terminal:

 

Introducing if…do

Below is the if…do block, found in the CONTROL category:

The if…do block only works if you attach another block that makes a comparison. For example, the compare values block from the OPERATORS > NUMBERS category as shown here:

To use this block, insert two values and select a comparison to make between them from the drop-down menu. The block evaluates the comparison statement and provides a value of 1 if the statement is true, or 0 if the statement is false.


Did You Know?

The = symbol is called a relational operator.  Here is the list of relational operators in the compare values drop down menu:
=       Equal to
≠       Not equal to
<       Less than
≤       Less than or equal to
>       Greater than
≥       Greater than or equal to


Sometimes, you may need to do one action if a condition is true, and a different action if it is false.  In its original form, the if…do block only completes an action if the condition is true. You can, however, alter the if…do block.

The if…do block is a unique mutating block, meaning you can change how it works. Click on the blue gear icon in front of the word “if,” and a box will pop up for selecting options:

 

Try This

  • Click on the blue gear to change the if…do block.
  • Drag an else block into the if block:

  • Click the blue gear icon again to shrink the options.
  • Attach your newly modified if…do block to the end of your program.
  • Remove the Terminal new line block and check the “then a new line” box.
  • Add more blocks to your program until it looks like this:

  • Load your program to RAM.
  • When the Terminal opens, click on the Terminal and type your first name.
  • Press enter/return.
  • Observe what prints out in the terminal:

   or

 

Your Turn

What if you want to test whether the name you entered is exactly 7 letters long, in addition to testing whether it is greater or less than 7 letters long?  You can mutate the if…do block again to include an else if condition:

  • Now, try building a program that gives a different message depending on what you enter, such as your age, what month you were born, or your favorite color.

Printer-friendly version
Values and Math Blocks
Prev
Make Complex Decisions
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress