Skip to content

12. Input Devices – Group Kuriyama

This is group assignment page of Computer-controlled cutting (Kuriyama Student) :

Group assignment

  • Probe an input device’s analog levels and digital signals

What we’ve done this week

  • Probe an input device’s digital signals (Atsufumi Suzuki)

Probe HC-SR04 (Ultra sonic sensor)

HCSR04 datasheet

  • 5V Supply
  • Trigger Pulse Input
  • Echo Pulse Output
  • 0V Ground

Electric Parameter

Electric Parameter parameter
Working Voltage DC 5 V
Working Current 15mA
Working Frequency 40Hz
Max Range 4m
Min Range 2cm
MeasuringAngle 15 degree
Trigger Input Signal 10uS TTL pulse
Echo Output Signal Input TTL lever signal and the range in proportion
Dimension 45 x 20 x 15mm

First, I used an oscilloscope to measure the pulse waveforms on the trig and Echo pins.


const int TRIG_PIN  = 0; 
const int ECHO_PIN  = 1;  

float duration_us, distance_cm;

void setup() {
  Serial.begin (9600);
  pinMode(TRIG_PIN, OUTPUT); 
  pinMode(ECHO_PIN, INPUT); 

void loop() {

  digitalWrite(TRIG_PIN, HIGH);
  digitalWrite(TRIG_PIN, LOW);

  duration_us = pulseIn(ECHO_PIN, HIGH);

  distance_cm = 0.017 * duration_us;

  Serial.print("distance: ");
  Serial.println(" cm");


In the void loop, the triger pin is changed from high (5v) to low (0v) at 10ms intervals.

  digitalWrite(TRIG_PIN, HIGH);
  digitalWrite(TRIG_PIN, LOW);

The following was confirmed by oscilloscope.


I connect with photoresistor.

and check the wave of signal.

You can see constantly taking the analog signal.


Last update: May 1, 2022