Help with Compiler Errors

Hello, I am getting the following errors on my ball_and_beam_pid project.

F:\myArduino\Ball_Beam_Servo\ball_and_beam\ball_and_beam.ino:36:1: error: 'HCSR04' does not name a type
 HCSR04 sensor(TRIG_PIN, ECHO_PIN);
 ^~~~~~
F:\myArduino\Ball_Beam_Servo\ball_and_beam\ball_and_beam.ino: In function 'void readSensor()':
F:\myArduino\Ball_Beam_Servo\ball_and_beam\ball_and_beam.ino:74:20: error: 'sensor' was not declared in this scope
   double reading = sensor.dist();
                    ^~~~~~
F:\myArduino\Ball_Beam_Servo\ball_and_beam\ball_and_beam.ino:74:20: note: suggested alternative: 'perror'
   double reading = sensor.dist();
                    ^~~~~~
                    perror

exit status 1

Compilation error: 'HCSR04' does not name a type

Here are my included files:
#include "PID_v1.h"
#include "HCSR04.h"
#include <AccelStepper.h>
#include "SimpleKalmanFilter.h"

I downloaded the HCSR04.h and HCSR04.cpp and zipped them up and included the zip in my project.
ball_and_beam.zip (12.8 KB)

What am I doing wrong?

Thank you very much,
Joe

  • Try:
    #include <HCSR04.h>

Your class is called HCSR04Sensor, not HCSR04.

Further the constructor for that class does not take arguments.

OP has a local copy of the files in the sketch directory. Using your approach will ignore that copy.

  • I never remember “ ” vs < >