Skip to content

Import code from the PASCO Code Library

Import a program that contains code you can edit and build upon.

The PASCO Code Library contains sample programs that work with the //code.Node (PS-3231) and //control.Node (PS-3232). The PASCO Code Library button is visible only when you connect a device.

Import a program

  1. Click the PASCO Code Library at the top of the Blockly workspace.
  2. Select a category from the menu.
  3. Select a program from the list. A description of the program is provided at the bottom of the window.
  4. Click OK to import the program.

When you open the program, the functions and other blocks might be collapsed to avoid cluttering the workspace. If you want to explore how the program works or make modifications, you can expand the blocks to see the details.

//code.Node programs

Import programs designed for use with the //code.Node (PS-3231).

Scroll Text

This program contains a function that can scroll text in the //code.Node's 5x5 LED array. The function takes two parameters:

  • Text: Enter characters in the text block to scroll across the array. You can enter any letter or number and the following symbols: ., /, +, -, =, and !.
  • Number of Times: Enter a value for the number of times the text scrolls across the array.

Play Music

This program contains a function that plays a song on the //code.Node's speaker. The function takes two parameters:

  • Tempo: Enter a number to control how fast the song plays. A higher number corresponds with a faster tempo.
  • Song: This contains a list of text blocks to enter the song notes. Each text block can represent a measure in a song.

To create a song, enter notes as letters in the text blocks of the Song list. Rests are represented by forward slashes (/). You can modify the notes and rests in the following ways:

  • Sharps and flats

    Enter a # or b following the note. For example, A# represents A-sharp and Ab represents A-flat.

  • Octaves

    Enter a number before the note to set the note octave. For example, 4A plays the note A4, which is typically 440 Hz. This also sets all following notes to the same octave until you set a new octave.

  • Duration

    Enter a number after a note or rest to set the duration it's played. The number represents the inverse of the duration. A 2 represents half, a 4 represents a quarter, and so forth. For example, A4 plays an A as a quarter note. This also sets all following notes and rests at the same duration until you set a new duration.

  • Dotted notes and rests

    A dot increases the duration by half. Enter * after the note or rest, such as A*.

  • Ties

    Tie a note between measures by entering a ~ after the note. In the following example, a G note is tied between two measures to play for a duration equal to a whole note plus a half note. If the ~ was missing, this code would play two separate G notes.

//code.Node Invaders

This program provides code for an arcade game displayed on the LED array. The game’s objective is to eliminate alien invaders before they reach the bottom of the array. Use the accelerometer to move the cannon by tilting left and right, and press button 2 to fire the laser. When the game is over, the array displays the number of targets eliminated.

Repeat Pattern

This program provides code for a memory game displayed on the LED array. The program displays a pattern by flashing lines on the left and right sides of the array. The objective is to repeat the pattern by pressing buttons 1 and 2, corresponding to the array’s left and right sides. The game increases in difficulty with each successful match by adding one additional item to the pattern. When the game is over, the array displays the total number of correct patterns.

PASCObot programs

Import programs designed for use with the PASCObot (PS-2994).

Note

For the PASCObot functions to work correctly, connect the stepper motor on the right side of the bot to Power Out port A on the //control.Node.

Move a Distance

This program includes a function that moves the PASCObot a specified distance. The function includes a parameter to enter the distance in centimeters. Enter a positive number to move the bot forward or a negative number to move the bot backward.

Move with Velocity

This program includes a function that moves the PASCObot continuously at a specified velocity. The function includes a parameter to enter the velocity in cm/s. Enter a positive number to move the bot forward or a negative number to move the bot backward.

Turn Left or Right

This program includes two functions that turn the PASCObot 90° left or 90° right. To use the functions, just include the function block in your code.

Rotate

This program includes a function that turns the PASCObot at a specified angle. The function includes a parameter to enter the angle in degrees. Enter a positive number to turn the bot right or a negative number to turn the bot left.

Follow Line

This program includes a function that makes the PASCObot follow a black or white line when used with the PASCObot Line Follower Module (PS-3320). The function includes two parameters:

  • Line intensity (%)

    This parameter indicates the approximate maximum intensity measured by the Line Follower module when placed over the line.

  • Surface intensity (%)

    This parameter indicates the approximate maximum intensity measured by the Line Follower module when placed over the surface it's moving on, such as a floor or table.

Before using the function, record some sample measurements of the line and surface intensity to determine what values to enter in the parameters. You should disable code execution so that the program doesn't run when measuring the intensities.

For detailed step-by-step instructions, see Getting started with the line follower.

Maintain Range

This program includes a function that uses the PASCObot Range Finder Module (PS-3321). Use this function to move the bot within a specified distance of an object in front of it and maintain that distance. For example, if you place an object in front of the bot, the bot will move towards the object until the distance is equal to the value entered in the function's parameter. If you move the object closer to the bot, the bot will move backwards to maintain the distance specified in the parameter.

For detailed step-by-step instructions, see Getting started with the Range Finder.

Control Gripper

This program includes four functions that use the PASCObot Gripper Accessory (PS-3325) with two Servo Motors (SE-2975). Use the functions to lower, raise, open, and close the Gripper arms. Each function includes a variable that sets the servo angle. If needed, you can change the angles to values that work best with your setup.