User Manual
Print

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