> 
 > 
5. Blocks Coding with Raspberry Pi
Grove
Grove

This documentation covers Grove system functionalities, including digital and analog port operations, servo and motor control, sensor data reading, four-digit display management, and additional features like playing sound.

Digital

Get the port result

Digital read port

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo</variable><variable>faceDetectionResult</variable></variables><block type=\"Grove_digitalRead\" disabled=\"true\" x=\"158\" y=\"293\"><field name=\"port\">GroveDigitalPort.D5</field></block></xml>"}

This is used to get the value from the specific port.

Parameters: N/A

Condition: D5 (Default)/D16/D18/D22/D26

Output: Number
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"Grove_digitalRead\"><field name=\"port\">GroveDigitalPort.D5</field></block></value></block></statement></block></xml>"}

The output:

Digital Read Port - Output

Modifying port value

Digital write port to

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Grove_digitalWrite\" disabled=\"true\" x=\"23\" y=\"202\"><field name=\"port\">GroveDigitalPort.D5</field><value name=\"signal\"><shadow type=\"math_number\" disabled=\"true\"><field name=\"NUM\">0</field></shadow></value></block></xml>"}

This is used to make modify the port value.

Parameters: N/A

Condition: D5 (Default)/D16/D18/D22/D26

Output: Number
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"Grove_digitalWrite\"><field name=\"port\">GroveDigitalPort.D5</field><value name=\"signal\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow></value></block></statement></block></xml>"}

The output:

Digital Read Port - Output
Digital Write Port to - Output 2

Analog

Reading the Current Voltage

Analog read port input voltage

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Grove_analogReadVoltage\" disabled=\"true\" x=\"-22\" y=\"337\"><field name=\"port\">GroveAnalogPort.A0</field></block></xml>"}

This is used for reading the current voltage of the hardware.

Parameters: N/A

Condition: A0 (Default)/A2/A4/A6

Output: Number
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"Grove_analogReadVoltage\"><field name=\"port\">GroveAnalogPort.A0</field></block></value></block></statement></block></xml>"}

The output:

Analog Read Port Input Voltage - Output

Reading the Current Raw Data

Analog read port raw data

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Grove_analogReadRaw\" disabled=\"true\" x=\"113\" y=\"337\"><field name=\"port\">GroveAnalogPort.A0</field></block></xml>"}

This is used for reading the current data of the hardware.

Parameters: N/A

Condition: A0 (Default)/A2/A4/A6

Output: Number
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"Grove_analogReadRaw\"><field name=\"port\">GroveAnalogPort.A0</field></block></value></block></statement></block></xml>"}

The output:

Analog Read Port Raw Data - Output

Scanning the Current Valur of the Hardware

Analog read port

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Grove_analogRead\" disabled=\"true\" x=\"113\" y=\"292\"><field name=\"port\">GroveAnalogPort.A0</field></block></xml>"}

This is used for reading the current value of the hardware that is linked to the corresponding port.

Parameters: N/A

Condition: A0 (Default)/A2/A4/A6

Output: Number
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"Grove_analogRead\"><field name=\"port\">GroveAnalogPort.A0</field></block></value></block></statement></block></xml>"}

The output:

Analog Read Port - Output

Servo

Change Motor Direction

Servo write port to degree

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Grove_servoDegreeSet\" disabled=\"true\" x=\"23\" y=\"607\"><field name=\"port\">GrovePWMPort.PWM</field><value name=\"degree\"><shadow type=\"math_number_minmax\" disabled=\"true\"><mutation min=\"0\" max=\"180\" label=\"Degree\" precision=\"0\"/><field name=\"SLIDER\">90</field></shadow></value></block></xml>"}

This is used to change the angle of the motor.

Parameters: N/A

Condition: 

  • PWM(Default)/D5/D16/D18/D22/D26
  • Number(Default: 90)

Output: Motor
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"Grove_servoDegreeSet\"><field name=\"port\">GrovePWMPort.PWM</field><value name=\"degree\"><shadow type=\"math_number_minmax\"><mutation min=\"0\" max=\"180\" label=\"Number\" precision=\"0\"/><field name=\"SLIDER\">90</field></shadow></value></block></statement></block></xml>"}

The output:

Servo Write Port to Degree - Output 1
Servo Write Port to Degree - Output 2
Servo Write Port to Degree - Output 3

Sensor

Get the Gesture Value of the Sensor

Gesture Sensor : Get gesture value

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>GestureSens

Initialize Gesture Value

Initiate Gesture Sensor

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>GestureSensor</variable></variables><block type=\"Grove_initGestureSensor\" disabled=\"true\" x=\"-22\" y=\"202\"/></xml>"}

Reading the Current Light Value

Light Sensor read port

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>GestureSensor</variable></variables><block type=\"Grove_groveLightSensorRead\" disabled=\"true\" x=\"-22\" y=\"247\"><field name=\"channel\">GroveAnalogPort.A0</field></block></xml>"}

This is used for reading the current light value from the light sensor.

Parameters: N/A

Condition: A0 (Default)/A2/A4/A6

Output: Number
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"Grove_groveLightSensorRead\"><field name=\"channel\">GroveAnalogPort.A0</field></block></value></block></statement></block></xml>"}

The output:

Light Senso Read Port - Output

Reading the Current Value of Rotary Angle Sensor

Rotary Angle Sensor read port

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Grove_rotaryAngleSensorRead\" disabled=\"true\" x=\"112\" y=\"292\"><field name=\"channel\">GroveAnalogPort.A0</field></block></xml>"}

This is used for reading the current value from the rotary angle sensor.

Parameters: N/A

Condition: A0 (Default)/A2/A4/A6

Output: Number
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>index</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"pxt_controls_for\"><value name=\"VAR\"><shadow type=\"variables_get_reporter\"><field name=\"VAR\">index</field></shadow></value><value name=\"TO\"><shadow type=\"math_whole_number\"><field name=\"NUM\">10</field></shadow></value><statement name=\"DO\"><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"Grove_rotaryAngleSensorRead\"><field name=\"channel\">GroveAnalogPort.A0</field></block></value><next><block type=\"basic_sleep\"><value name=\"ms\"><shadow type=\"math_number\"><field name=\"NUM\">1000</field></shadow></value></block></next></block></statement></block></statement></block></xml>"}

The output:

Rotary Angle Sensor Read Port - Output 1
Rotary Angle Sensor Read Port - Output 2

Scanning the Current Value from Ultrasonic Ranger Read Sensor

Ultrasonic ranger read(cm) port

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>index</variable></variables><block type=\"Grove_ultrasonicReadCm\" disabled=\"true\" x=\"22\" y=\"338\"><field name=\"port\">GroveDigitalPort.D5</field></block></xml>"}

This is used for reading the current value from the ultrasonic ranger read sensor.

Parameters: N/A

Condition: A0 (Default)/A2/A4/A6

Output: Number
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>index</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"pxt_controls_for\"><value name=\"VAR\"><shadow type=\"variables_get_reporter\"><field name=\"VAR\">index</field></shadow></value><value name=\"TO\"><shadow type=\"math_whole_number\"><field name=\"NUM\">10</field></shadow></value><statement name=\"DO\"><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"Grove_ultrasonicReadCm\"><field name=\"port\">GroveDigitalPort.D5</field></block></value><next><block type=\"basic_sleep\"><value name=\"ms\"><shadow type=\"math_number\"><field name=\"NUM\">1000</field></shadow></value></block></next></block></statement></block></statement></block></xml>"}

The output:

Ultrasonic - Output 1
Ultrasonic - Output 2
Ultrasonic - Output 3

Motor Driver

Set the Address of Motor Driver

Create Motor Driver with address switch 1 2 3 4

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>index</variable></variables><block type=\"Grove_createMotorDriver\" disabled=\"true\" x=\"-22\" y=\"428\"><field name=\"s1\">Switch.ON</field><field name=\"s2\">Switch.ON</field><field name=\"s3\">Switch.ON</field><field name=\"s4\">Switch.ON</field></block></xml>"}

This is used for setting the motor driver with the correct address.

Parameters: N/A

Condition: ON (Default)/OFF

Output: N/A
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>MotorDriver</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">MotorDriver</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Grove_createMotorDriver\"><field name=\"s1\">Switch.ON</field><field name=\"s2\">Switch.ON</field><field name=\"s3\">Switch.ON</field><field name=\"s4\">Switch.ON</field></block></value><next><block type=\"Grove_MotorDriver_setMotorOffset\"><field name=\"motor\">GroveMotorDriverConstant.M1</field><value name=\"MotorDriver\"><block type=\"variables_get\"><field name=\"VAR\">MotorDriver</field></block></value><value name=\"speed\"><shadow type=\"math_number_minmax\"><mutation min=\"0\" max=\"100\" label=\"Number\" precision=\"0\"/><field name=\"SLIDER\">100</field></shadow></value></block></next></block></statement></block></xml>"}

The output:

Motor Driver : set motor M1 with speed - Output 1
Motor Driver : set motor M1 with speed - Output 2

Set the Motor Driver Speed

Motor Driver : set motor M1 with speed

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>MotorDriver</variable></variables><block type=\"Grove_MotorDriver_setMotorOffset\" disabled=\"true\" x=\"23\" y=\"383\"><field name=\"motor\">GroveMotorDriverConstant.M1</field><value name=\"MotorDriver\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">MotorDriver</field></block></value><value name=\"speed\"><shadow type=\"math_number_minmax\" disabled=\"true\"><mutation min=\"0\" max=\"100\" label=\"Offset\" precision=\"0\"/><field name=\"SLIDER\">0</field></shadow></value></block></xml>"}

This is used for setting the motor driver speed to make the motor driver move.

Parameters:Motor Driver

Condition: 

  • M1 (Default)/M2
  • Number (Default: 0)

Output: N/A
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>MotorDriver</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">MotorDriver</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Grove_createMotorDriver\"><field name=\"s1\">Switch.ON</field><field name=\"s2\">Switch.ON</field><field name=\"s3\">Switch.ON</field><field name=\"s4\">Switch.ON</field></block></value><next><block type=\"Grove_MotorDriver_setMotorOffset\"><field name=\"motor\">GroveMotorDriverConstant.M1</field><value name=\"MotorDriver\"><block type=\"variables_get\"><field name=\"VAR\">MotorDriver</field></block></value><value name=\"speed\"><shadow type=\"math_number_minmax\"><mutation min=\"0\" max=\"100\" label=\"Number\" precision=\"0\"/><field name=\"SLIDER\">100</field></shadow></value></block></next></block></statement></block></xml>"}

The output:

Motor Driver : set motor M1 with speed - Output 1
Motor Driver : set motor M1 with speed - Output 2

Four Digit Display

Set the Position of Four Digit Display

Create Four Digit Display with port

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>MotorDriver</variable></variables><block type=\"Grove_createFourDigitDisplay\" disabled=\"true\" x=\"157\" y=\"472\"><field name=\"port\">GroveDigitalPort.D5</field></block></xml>"}

This is used for setting the four digit display in the correct position.

Parameters: N/A

Condition: D5 (Default)/D16/D18/D22/D26

Output: N/A
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">FourDigitDisplay</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Grove_createFourDigitDisplay\"><field name=\"port\">GroveDigitalPort.D5</field></block></value><next><block type=\"Grove_FourDigitDisplay_setColon\"><field name=\"status\">Switch.ON</field><value name=\"FourDigitDisplay\"><block type=\"variables_get\"><field name=\"VAR\">FourDigitDisplay</field></block></value></block></next></block></statement></block></xml>"}

The output:

Create Four Digit Display with Port - Output 1
Create Four Digit Display with Port - Output 2

Set the Colon Light of Four Digit Display

Four Digit Display : Set Colon

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"Grove_FourDigitDisplay_setColon\" disabled=\"true\" x=\"23\" y=\"247\"><field name=\"status\">Switch.ON</field><value name=\"FourDigitDisplay\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">FourDigitDisplay</field></block></value></block></xml>"}

This is used for setting the four-digit display colon light to be on or off.

Parameters: Four Digit Display

Condition: ON (Default)/OFF

Output: Four Digit Display
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">FourDigitDisplay</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Grove_createFourDigitDisplay\"><field name=\"port\">GroveDigitalPort.D5</field></block></value><next><block type=\"Grove_FourDigitDisplay_setColon\"><field name=\"status\">Switch.ON</field><value name=\"FourDigitDisplay\"><block type=\"variables_get\"><field name=\"VAR\">FourDigitDisplay</field></block></value></block></next></block></statement></block></xml>"}

The output:

Create Four Digit Display with Port - Output 1
Create Four Digit Display with Port - Output 2

Set the Brightness of Four Digit Display

Four Digit Display : Set Colon

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"Grove_FourDigitDisplay_setBrightness\" disabled=\"true\" x=\"23\" y=\"247\"><value name=\"FourDigitDisplay\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">FourDigitDisplay</field></block></value><value name=\"brightness\"><shadow type=\"math_number_minmax\" disabled=\"true\"><mutation min=\"0\" max=\"7\" label=\"Brightness\" precision=\"0\"/><field name=\"SLIDER\">2</field></shadow></value></block></xml>"}

This is used for setting the brightness of the light for the four-digit display.

Parameters: Four Digit Display

Condition: Number (Default: 2)

Output: Four Digit Display
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">FourDigitDisplay</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Grove_createFourDigitDisplay\"><field name=\"port\">GroveDigitalPort.D5</field></block></value><next><block type=\"Grove_FourDigitDisplay_setBrightness\"><value name=\"FourDigitDisplay\"><block type=\"variables_get\"><field name=\"VAR\">FourDigitDisplay</field></block></value><value name=\"brightness\"><shadow type=\"math_number_minmax\"><mutation min=\"0\" max=\"7\" label=\"Number\" precision=\"0\"/><field name=\"SLIDER\">7</field></shadow></value><next><block type=\"Grove_FourDigitDisplay_showNumber\"><value name=\"FourDigitDisplay\"><block type=\"variables_get\"><field name=\"VAR\">FourDigitDisplay</field></block></value><value name=\"num\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow></value></block></next></block></next></block></statement></block></xml>"}

The output:

Four Digit Display Set Brightness - Output 1
Four Digit Display Set Brightness - Output 2

Display the number of Four Digit Display

Four Digit Display : Show Number

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"Grove_FourDigitDisplay_showNumber\" disabled=\"true\" x=\"23\" y=\"473\"><value name=\"FourDigitDisplay\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">FourDigitDisplay</field></block></value><value name=\"num\"><shadow type=\"math_number\" disabled=\"true\"><field name=\"NUM\">0</field></shadow></value></block></xml>"}

This is used for showing the numeric value for the four-digit display.

Parameters: Four Digit Display

Condition: Number (Default: 0)

Output: Four Digit Display (Number)
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">FourDigitDisplay</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Grove_createFourDigitDisplay\"><field name=\"port\">GroveDigitalPort.D5</field></block></value><next><block type=\"Grove_FourDigitDisplay_showNumber\"><value name=\"FourDigitDisplay\"><block type=\"variables_get\"><field name=\"VAR\">FourDigitDisplay</field></block></value><value name=\"num\"><shadow type=\"math_number\"><field name=\"NUM\">88</field></shadow></value></block></next></block></statement></block></xml>"}

The output:

Four Digit Display Show Number - Output 1
Four Digit Display Show Number - Output 2

Display the text of Four Digit Display

Four Digit Display : Show Text

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"Grove_FourDigitDisplay_showText\" disabled=\"true\" x=\"23\" y=\"472\"><value name=\"FourDigitDisplay\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">FourDigitDisplay</field></block></value><value name=\"txt\"><shadow type=\"text\" disabled=\"true\"><field name=\"TEXT\"/></shadow></value></block></xml>"}

This is used for showing the text for the four-digit display.

Parameters: Four Digit Display

Condition: Text

Output: Four Digit Display (Text)
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">FourDigitDisplay</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Grove_createFourDigitDisplay\"><field name=\"port\">GroveDigitalPort.D5</field></block></value><next><block type=\"Grove_FourDigitDisplay_showText\"><value name=\"FourDigitDisplay\"><block type=\"variables_get\"><field name=\"VAR\">FourDigitDisplay</field></block></value><value name=\"txt\"><shadow type=\"text\"><field name=\"TEXT\">HI</field></shadow></value></block></next></block></statement></block></xml>"}

The output:

Four Digit Display Show Text- Output 1
Four Digit Display Show Text- Output 2

Clear the Value of Four Digit Display

Four Digit Display : Clear

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"Grove_FourDigitDisplay_clear\" disabled=\"true\" x=\"23\" y=\"562\"><value name=\"FourDigitDisplay\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">FourDigitDisplay</field></block></value></block></xml>"}

This is used for deleting the values that are displayed in the four digit display.

Parameters: Four Digit Display

Output: Four Digit Display 
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">FourDigitDisplay</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Grove_createFourDigitDisplay\"><field name=\"port\">GroveDigitalPort.D5</field></block></value><next><block type=\"Grove_FourDigitDisplay_clear\"><value name=\"FourDigitDisplay\"><block type=\"variables_get\"><field name=\"VAR\">FourDigitDisplay</field></block></value></block></next></block></statement></block></xml>"}

The output:

Four Digit Display Clear - Output 1
Four Digit Display Clear - Output 2

Others

Play Sound

Speaker port play tone for beat(s)

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>FourDigitDisplay</variable></variables><block type=\"Grove_speaker\" disabled=\"true\" x=\"23\" y=\"697\"><field name=\"port\">GroveDigitalPort.D5</field><field name=\"tone\">SpeakerTone.LC</field><field name=\"beat\">BeatFraction.Whole</field></block></xml>"}

This is used for play different sound in the speaker.

Parameters: N/A

Condition:     

  • D5 (Default)/D16/D18/D22/D26
  • Low_C(Default)/Low_D/Low_E/Low_F/Low_G/Low_A/Low_B/Middle_C/Middle_D/Middle_E/Middle_F/Middle_G/Middle_A/Middle_B/High_C/High_D/High_E/High_F/High_G/High_A/High_B
  • 1 (Default) / 1/2 / 1/4 / 1/8 / 1/16 / 2 / 4

Output: Speaker
Sample code:

{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"Grove_speaker\"><field name=\"port\">GroveDigitalPort.D5</field><field name=\"tone\">SpeakerTone.LC</field><field name=\"beat\">BeatFraction.Whole</field></block></statement></block></xml>"}

The output:

Speaker port play tone ... for ... beat - Output

Table of Content