How Can We Help?

Block Reference

Block Reference

This section includes detailed introduction of each block category.

Looks

LED Dot-Matrix Display

image

The face panel of Codey is a 128-LED dot matrix, which can display English characters, numbers, and images.

Coordinate of the Face Panel

image

As shown in the figure above, the face panel has the upper-left corner as the origin of the coordinate system, and the direction of x and y is indicated by the arrow. Parameters:

  • x: -15 ~ 15
  • y: -7 ~ 7

1. show image () for () secs

Display specified image on Codey’s screen for a specified period of time.

image

Example:

image

Press Button A, Codey’s screen will display these three images consecutively, for 1 second, 0.5 second, and 1 second respectively. After displaying all images, Codey’s screen will turn off.

2. show image ()

Display specified image on Codey’s screen.

image

Example:

image

When Codey starts up, the image will be displayed.

3. show image () at the x:() y:()

Display specified image at specified point of the face panel.

image

Example:

image

Press Button A, the image will be displayed at the origin.

4. turn off screen

Turn off Codey’s screen.

image

Example:

image

Press Button A, the image will be displayed at the origin. One second later, the screen will turn off.

5. show ()

Display English characters, numbers and symbols on Codey’s screen.

image

Example:

image

Press Button A, Codey’s screen will display “12:00”.

6. show () until scroll done

Display English characters, numbers and symbols on Codey’s screen, and scroll all contents.

image

Example:

image

Press Button A, Codey’s screen will scroll “morning”.

7. show () at x:() y:()

Display English characters, numbers and symbols at specified point of the face panel.

image

Example:

image

Press Button A, Codey’s screen will display “hi” at the origin.

8. light up x:() y:()

Light up specified dot (x, y) of Codey’s face panel.

image

Parameters:

  • x: 0 ~ 15
  • y: 0 ~ 7

Example:

image

Press Button A, the dot at (3, 3) will light up.

9. light off x:() y:()

Light off specified dot (x, y) of Codey’s face panel.

image

Parameters:

  • x: 0 ~ 15
  • y: 0 ~ 7

Example:

image

Press Button A, the dot at (2, 2) will light up, and light off after one second.

10. switch between light-up and light-off x:() y:()

Change the status of specified dot (x, y) of Codey’s face panel: light off light-up dot; light up light-off dot.

image

Parameters:

  • x: 0 ~ 15
  • y: 0 ~ 7

Example:

image

Press Button A, the dot at (6, 6) will light up. Press Button A again, the dot will light off.

11. x:() y:() is it lighted up?

If specified dot (x, y) of Codey’s face panel is lighted up, the report condition is met.

image

Parameters:

  • x: 0 ~ 15
  • y: 0 ~ 7

Example:

image

Press Button A, the dot (3, 3) and (5, 5) of Codey’s face panel will light up. After 3 seconds, the dot (3, 3) will light off.

Lighting

RGB LED

image

The RGB LED is situated at the bottom Codey’s face panel. Codey’s RGB LED consists of 3 LEDs, namely red LED, green LED, and blue LED. You can get different colors by controling brightness of each LED.

image

At the center of Rocky’s Color IR Sensor is the RGB LED, which consists of 3 LEDs, red LED, green LED, and blue LED. By lighting on or off each LED, you can get seven different colors.

1. RGB LED lights up () for () secs

Light up Codey’s RGB LED a specified color for a specified period of time.

image

Example:

image

Press Button A, Codey’s LED will light up red, and light off after 1 second.

2. RGB LED lights up ()

Light up Codey’s RGB LED a specified color.

image

Example:

image

Press Button A, Codey’s LED will light up red.

3. set the indicator () with color value ()

Set the specified LED indicator with specified color value. There are three LED indicators: red, green, and blue.

image

Change the color value of one LED indicator will not affect the color value of the other two LED indicators.

Parameters:

  • Red: 0 ~ 255
  • Green: 0 ~ 255
  • Blue: 0 ~ 255

Example:

image

Press Button A, Codey’s RGB LED will light up yellow.

4. RGB LED lights off

Turn off Codey’s RGB LED.

image

Example:

image

Press Button A, Codey’s RGB LED will light up yellow, and light off after 3 seconds.

5. set Rocky’s light with color ()

Set Rocky’s RGB LED a specified color. There are seven colors: red, green, blue, yellow, cyan, purple, and white.

image

Example:

Press Button A, Rocky’s RGB LED will light up blue.

6. Rocky lights off

Turn off Rocky’s RGB LED.

image

Example:

image

Press Button A, Rocky’s RGB LED will light up blue, and light off after 2 seconds.

Speaker

Codey’s on-board speaker enables Codey to play sound. You can write music, add sound effects, and do other fun stuff with Codey’s speaker.

1. play sound ()

Make Codey’s speaker play a specified sound.

image

Sound Effect
hello hi bye yeah wow laugh hum
sad sigh annoyed angry scared pettish curious
embarrassed ready sprint snore meow start switch
beeps buzz air-out explosion gotcha painful jump
laser level-up low-energy metal-clash prompt-tone right wrong
ringtone score shot step_1 step_2 activate warning

Example:

image

Press Button A. Codey will play the sound “hello”.

2. play sound () until done

Make Codey’s speaker play a specified sound, and wait until it’s done.

image

Example:

image

Press Button A. Codey will play the sound “hello”.

3. stop all sounds

Make Codey’s speaker stop playing all sounds.

image

Example:

image

Press Button A. Codey will play the sound “hello” for 10 times, and then stop all sounds.

4. play note () for () beats

Make Codey’s speaker play a specified note for specified number of beats.

image

Example:

image

Press Button A. Codey will play the note “C4” for 0.25 beat.

5. rest for () beats

Make Codey’s speaker stop playing sounds and wait for specified number of beats.

image

Example:

image

Press Button A. Codey will play the note “C4” for 0.25 beat 5 times, and after waiting for 0.25 beat, play the note “G4” for 0.25 beat 5 times.

6. play sound at frequency of () HZ for () secs

Make Codey’s speaker play sound at specified frequency for a specified period of time.

image

Example:

image

Press Button A. Cody will play a 700Hz sound for one second.

7. change volume by ()

Change the sound volmue of Codey’s speaker. Input positive number to increase sound volume, or negative number to decrease sound volume.

image

Example:

image

Press Button A to decrease sound volume of Codey’s speaker by 10.

8. set volume to ()%

Set the sound volume of Codey’s speaker to specified percentage (0 ~ 100).

image

Example:

image

When Codey starts up, the sound volume of the speaker will be set to 60%.

9. volume

Report the sound volume of Codey’s speaker.

image

Example:

image

Press Button A. The current sound volume of Codey’s speaker will be displayed on the screen.

Action

image

When Codey and Rocky are combined together, Codey Rocky can move. You can make Codey Rocky move forward or backward, turn left or right, or other more complicated movements. With the help of gyroscope, you can make Codey Rocky turn left/right a specified number of degrees, or move straight forward.

1. move forward at power ()% for () secs

Make Codey Rocky move forward at specified power for a specified period of time.

image

Parameters:

  • Power: -100 ~ 100 (negative number means opposite direction)
  • Time: 0 ~ ∞/second

Example:

image

When Codey starts up, Codey Rocky will move forward at 50% power for one second.

2. move backward at power ()% for () secs

Make Codey Rocky move backward at specified power for a specified period of time.

image

Parameters:

  • Power: -100 ~ 100 (negative number means opposite direction)
  • Time: 0 ~ ∞/second

Example:

image

When Codey starts up, Codey Rocky will move backward at 50% power for one second.

3. turn left at power ()% for () secs

Make Codey Rocky move turn left at specified power for a specified period of time.

image

Parameters:

  • Power: -100 ~ 100 (negative number means opposite direction)
  • Time: 0 ~ ∞/second

Example:

image

When Codey starts up, Codey Rocky will turn left at 50% power for one second.

4. turn right at power ()% for () secs

Make Codey Rocky move turn right at specified power for a specified period of time.

image

Parameters:

  • Power: -100 ~ 100 (negative number means opposite direction)
  • Time: 0 ~ ∞/second

Example:

image

When Codey starts up, Codey Rocky will turn right at 50% power for one second.

5. keep straight forward at power ()% for () secs

Use Rocky’s gyroscope to make Codey Rocky move forward at the same direction at specified power for a specfied period of time.

image

Parameters:

  • Power: -100 ~ 100 (negative number means opposite direction)
  • Time: 0 ~ ∞/second

Example:

image

When Codey starts up, Codey Rocky will move straight forward at 50% power for one second.

6. keep straight backward at power ()% for () secs

Use Rocky’s gyroscope to make Codey Rocky move backward at the same direction at specified power for a specfied period of time.

image

Parameters:

  • Power: -100 ~ 100 (negative number means opposite direction)
  • Time: 0 ~ ∞/second

Example:

image

When Codey starts up, Codey Rocky will move straight backward at 50% power for one second.

7. turn left () degrees until done

Make Codey Rocky turn left specified degrees and wait until it’s done.

image

Parameter:

  • Angle: -∞ ~ ∞/degree (negative number means opposite direction)

Example:

image

When Codey starts up, Codey Rocky will turn left 15 degrees and then move forward at 50% power for one second.

8. turn right () degrees until done

Make Codey Rocky turn right specified degrees and wait until it’s done.

image

Parameter:

  • Angle: -∞ ~ ∞/degree (negative number means opposite direction)

Example:

image

When Codey starts up, Codey Rocky will turn right 15 degrees and then move forward at 50% power for one second.

9. () at power ()%

Make Codey Rocky move forward/backward, or turn left/right at specified power.

image

Parameter:

  • Power: -100 ~ 100 (negative number means opposite direction)

Example:

image

When Codey starts up, Codey Rocky will keep moving forward at 50% power.

10. left wheel turns at power ()% and right wheel at power ()%

Make the left wheel and right wheel of Codey Rocky move at specified power respectively.

image

Parameter:

  • Power: -100 ~ 100 (negative number means opposite direction)

Example:

image

When Codey starts up, both the left wheel and the right wheel will move at 50% power for one second.

11. stop moving

Make Codey Rocky stop moving.

image

Example:

image

When Codey starts up, Codey Rocky will move forward at 50% power for one second, and then stop moving.

Sensing Category

Codey

image

Rocky – Color Infrared Sensor

image

1. button () is pressed?

If the specified button of Codey is pressed, the report condition is met. There are three buttons: Button A, Button B, and Button C.

image

Example:

image

When Codey starts up, if Button A is pressed, Codey’s screen will display “Yes”. If Button A is not pressed, Codey’s screen will display “No”.

2. when Codey connected to Rocky

If Codey is connected to Rocky, the report condition is met.

image

Example:

image

When Codey starts up, if Codey is connected to Rocky, Codey’s screen will display “Yes”. If not, Codey’s screen will display “No”.

3. gear potentiometer value

Report the position of gear potentiometer. The range of the value is 0 ~ 100, rounded to nearest integer.

image

Example:

image

When Codey starts up, the gear potentiometer value will be displayed on Codey’s screen.

4. loudness

Report the loudness detected by Codey’s sound sensor. The range of the value is 0 ~ 100, rounded to nearest tenth.

image

Example:

image

When Codey starts up, the loudness value will be displayed on Codey’s screen.

5. ambient light intensity

Report the ambient light intensity detected by Codey’s light sensor. The range of the value is 0 ~ 100, rounded to nearest tenth.

image

Example:

image

When Codey starts up, the ambient light intensity value will be displayed on Codey’s screen.

6. battery level

Report Codey’s battery level (0 ~ 100, rounded to nearest ten).

image

Example:

image

When Codey starts up, the battery level will be displayed on Codey’s screen.

7. shaken?

If Codey is being shaken, the report condition is met.

image

Example:

image

When Codey starts up, if being shaken, Codey’s screen will display “Yes”. If not, Codey’s screen will display “No”.

8. shaking strength

Report the strength by which Codey is being shaken. The range of the shaking strength is 0 ~ 100, rounded to the nearest integer.

image

Example:

image

When Codey is being shaken, Codey’s screen will display the shaking strength.

9. Codey () tilted?

If Codey is tilted towards specified direction, the report condition is met. There are four directions: “tilted to the left”, “tilted to the right”, “ears up”, and “ears down”. The threshold value is 15 degrees.

image

Example:

image

When Codey starts up, if tilted to the left, Codey’s screen will display “Yes”. If not, Codey’s screen will display “No”.

10. Codey positioned as ()?

If Codey is positioned as the specified position, the report condition is met. There are three positions: “face up”, “face down”, and “stand on desk”.

image

Example:

image

When Codey starts up, if Codey is positioned face-up, Codey’s screen will display “Yes”. If not, Codey’s screen will display “No”.

11. roll angle°

Report Codey’s roll angle.

image

Parameter:

  • Roll: -90° ~ 90°, rounded to the nearest integer; positive number means right-tilted; invalid value will be set to zero.

Example:

image

When Codey starts up, the screen will display Codey’s roll angle.

12. pitch angle°

Report Codey’s pitch angle.

image

Parameter:

  • Roll: -180° ~ 180°, rounded to the nearest integer; positive number means ears-up; invalid value will be set to zero.

Example:

image

When Codey starts up, the screen will display Codey’s pitch angle.

13. rotation angle around x

Report Codey’s rotation angle around the x axis.

image

Example:

image

When Codey starts up, the screen will display Codey’s rotation angle around the x axis.

14. rotation angle around y

Report Codey’s rotation angle around the y axis.

image

Example:

image

When Codey starts up, the screen will display Codey’s rotation angle around the y axis.

15. rotation angle around z

Report Codey’s rotation angle around the z axis.

image

Example:

image

When Codey starts up, the screen will display Codey’s rotation angle around the z axis.

16. reset () rotation angle°

Reset Codey’s rotation angle around specified axis/axes. There are four options: x-axis, y-axis, z-axis, and all axes.

image

Example:

image

When Codey starts up, reset rotation angles around all axes.

17. timer

Report Codey’s timer value (second, rounded to nearest tenth).

image

Example:

image

When Codey starts up, Codey’s screen will display timer value.

18. reset timer

Reset Codey’s timer.

image

Example:

image

Press Button A to reset Codey’s timer.

19. obstacles ahead?

If Rocky’s color infrared sensor detects obstacles ahead, the report condition is met.

image

Example:

image

When Codey starts up, Codey Rocky will keep moving forward at 50% power. If Rocky detects obstacles ahead, Codey Rocky will stop moving.

20. the color detected is ()?

If the color detected is the specified color, the report condition is met. There are eight colors: red, green, blue, yellow, cyan, purple, black, and white.

image

Example:

image

When Codey starts up, if the color detected by Rocky’s color sensor is red, Rocky’s LED will light up red.

21. () color value detected?

Report the specified color value of the obstacle detected by Rocky’s color sensor. Colors include red, green, and blue.

image

Example:

image

When Codey starts up, if Rocky detects color red, the value of red will be displayed on Codey’s screen.

22. color sensor ambient light intensity

Report the value of ambient light intensity detected by Rocky’s color sensor.

image

Parameter:

  • Light intensity: 0 ~ 100, rounded to nearest tenth; value exceeding 100 will be displayed as the maximum 100.

Example:

image

When Codey starts up, Codey’s screen will display the value of amibent light intensity.

23. color sensor reflected light intensity

Report the value of reflected light intensity detected by Rocky’s color sensor.

image

Example:

image

When Codey starts up, Codey’s screen will display the value of reflected light intensity.

24. color sensor reflected infrared light intensity

Report the value of reflected infrared light intensity detected by Rocky’s color sensor.

image

Example:

image

When Codey starts up, Codey’s screen will display the value of reflected infrared light intensity.

25. color sensor grey-scale value

Report the grey-scale value detected by Rocky’s color sensor.

image

Example:

image

When Codey starts up, Codey’s screen will display the grey-scale value.

Infrared

1. send IR message

Send specified IR message.

image

Example:

image

Press Button A to send IR message A.

2. IR message received

Report the received IR message.

image

3. record home appliances remote signal 3 secs

Record the remote signal of home appliances for 3 seconds.

image

Example:

image

Press Button A to record the remote signal of home appliances for 3 seconds.

4. send home appliances remote signal

Send recorded remote signal of home appliances.

image

Example:

image

Press Button A to send recorded remote signal of home appliances.

Events

1. when Codey starts up

When Codey starts up, run the script.

image

Example:

When Codey starts up, the screen will display “hello”.

2. when button () is pressed

When the specified button is pressed, run the script.

image

Example:

image

When Button A is pressed, Codey will play the sound “hello”.

3. when Codey is shaking

When Codey is shaking, run the script.

image

Example:

image

When being shaken, Codey will play the sound “wow”.

4. when Codey is () tilted

If Codey tilts towards the specified direction, run the script. There are four options: “tilted to the left”, “tilted to the right”, “ears up”, and “ears down”.

image

Example:

image

When Codey is left-tilted, the screen will display “left”.

5. when () > ()

When the value of the specified parameter (loudness or timer) is greater than the specified value, run the script.

image

Example:

image

When the loudness detected is greater than 10, Codey’s screen will display current loudness.

6. when light intensity < ()

When detected light intensity is less than the specified value, run the script.

image

Example:

image

When the light intensity detected is less than 10, Codey’s LED will light up red.

7. when I receive ()

When Codey receives specified message, run the script.

image

Example:

image

When receiving “message1”, Codey will play the sound “laugh”.

8. broadcast ()

Broadcast specified message.

image

Example:

image

Press Button A. Codey will broadcast “message 1”.

Control

1. wait () seconds

Wait for a specified period of time to run the script.

image

Example:

image

Press Button A. One second later, Codey’s screen will display the image.

2. repeat ()

Run the script for the specified number of times.

image

Example:

image

When Codey starts up, it will play the sound “hello” for ten times.

3. forever

Run the script repeatedly.

image

Example:

image

When Codey starts up, Codey’s will repeated display the two images consecutively.

4. if () then ()

If the report condition is met, run the script.

image

Example:

image

When Codey starts up, if being shaken, Codey will play the sound “hello”.

5. if () then () else ()

If the report condition is met, run script 1. If not, run script 2.

image

Example:

image

When Codey starts up, if there are obstacles ahead, Codey Rocky will stop moving. If not, Codey Rocky will keep moving forward at 50% power.

6. wait ()

Wait until the report condition is met. Run the script.

image

Example:

image

After starting up, Codey Rocky will keep moving forward at 50% power until Rocky detects obstacles ahead.

7. repeat until ()

Run the script repeatedly until the report condition is met.

image

Example:

image

After starting up, Codey Rocky will keep moving forward at 50% power until Rocky detects obstacles ahead.

8. stop ()

Stop the specified script or scripts. There are three options: all, this script, or other scripts in sprite.

image

Example:

image

Press Button A to stop all scripts.

Operators

1. () + ()

Perform mathematical addition.

image

Example:

image

Press Button A. Codey’s screen will display the result of “2 + 3”.

2. () − ()

Perform mathematical subtraction.

image

Example:

image

Press Button A. Codey’s screen will display the result of “3 – 1”.

3. () * ()

Perform mathematical multiplication.

image

Example:

image

Press Button A. Codey’s screen will display the result of “2 × 3”.

4. () / ()

Perform mathematical division.

image

Example:

image

Press Button A. Codey’s screen will display the result of “6 ÷ 2”.

5. pick random () to ()

Pick a random number from the specified range.

image

Example:

image

Press Button A. Codey’s screen will display the image for a random number of seconds within the range of 1 to 10.

6. () > ()

If the value of the specified parameter is greater than the specified value, the report condition is met.

image

Example:

image

Shake Codey. If the shaking strength is greater than 10, Codey will play the sound “wow”.

7. () < ()

If the value of the specified parameter is less than the specified value, the report condition is met.

image

Example:

image

When Codey starts up, if battery level is lower than 50%, Codey’s screen will display “low battery”.

8. () = ()

If the value of the specified parameter equals the specified value, the report condition is met.

image

Example:

image

When Codey starts up, if the red value of the object detected equals 255, Codey’s LED will light up red.

9. () and ()

If both the conditions are met, the report condition is met.

image

Example:

image

After starting up, Codey Rocky will keep moving forward at 50% power until red obstacle is detected.

10. () or ()

If either one of the two conditions is met, the report condition is met.

image

Example:

image

When Codey starts up, Codey will play the sound “hello”, if Button A is pressed or if being shaken.

11. not ()

The report condition is met when the specified condition is not met.

image

Example:

image

When Codey starts up, if there no obstacle ahead, Codey Rocky will keep moving forward at 50% power.

12. join () ()

Join two specified character strings.

image

Example:

image

When Codey starts up, the screen will display “hi” and “morning” together.

13. letter () of ()

Report the letter at specified position of a character string.

image

Example:

image

When Codey starts up, the screen will display the third letter of “morning”.

14. length of ()

Report the length of a specified character string.

image

Example:

image

When Codey starts up, the screen will display the length of “morning.”

15. () contains ()?

If the specified character string contains the other specified character string, the report condition is met.

image

Example:

image

When Codey starts up, if “apple” contains “a”, Codey’s screen will display “yes”.

16. () mod ()

Calculate the remainder (modular) of two specified numbers.

image

Example:

image

When Codey starts up, the screen will display the remainder of “9 ÷ 6”.

17. round ()

Round the specified number to nearest integer.

image

Example:

image

When Codey starts up, the screen will display the result of rounding 10.7.

18. () ()

Perform specific mathematical operation on the specified number. Mathematical operations include: abs (absolute value), floor, ceiling, sqrt (square root), sin, sos, tan, asin, atan, acos, ln, log, e^, and 10^.

image

Example:

image

When Codey starts up, the screen will display the square root of 16.