I'm not certain that an HC SR-04 will work with Scratch, I'm not sure how well it would deal with the timing requirements.
The HC SR-04 has 4 pins:
Vcc: Voltage into sensor - this should be connected to one of the 5V Pins (Pins 2 or 4) (This sensor is unreliable at 3V3)
Trig: Trigger - connect to any of the numbered GPIO pins (your choice) set the pin as an output.
Echo: Return signal from the sensor - this will be at 5V, use a voltage divider to drop this to 3V3 and connect to another GPIO pin (set as an input)
Gnd: 0V, part of the sensors power supply.
- Sending a pulse to the trigger activates the HC SR-04 for a distance measuring cycle.
: Return signal from the sensor - this will be at 5V, use a voltage divider to drop this to 3V3. The Elapsed time between the Echo signal going high to it returning low is the indicator of the distance. (which may be a problem for scratch to measure).
covers connecting an Ultrasonic distance sensor fairly thoroughly.
Avoid using the GPIO numbers that the Ryantech robot kit uses (I don't know which ones they are), I'll try to find out for you.
Building Management Systems Engineer.