# Help with Compiler Errors

**URL:** <https://forum.arduino.cc/t/help-with-compiler-errors/1326277>\
**Category:** Programming\
**Created:** [November 27, 2024, 2:37am UTC](https://forum.arduino.cc/t/help-with-compiler-errors/1326277 "2024-11-27T02:37:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lindula](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/lindula/32/1099700_2.png) [@lindula](https://forum.arduino.cc/u/lindula)\
**Post date:** [November 27, 2024, 2:37am UTC](https://forum.arduino.cc/t/help-with-compiler-errors/1326277/1 "2024-11-27T02:37:09Z")

</div>

Hello, I am getting the following errors on my ball\_and\_beam\_pid project.

```arduino
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](https://forum.arduino.cc/uploads/short-url/7F2KWhIuQ1feq5JDOdhMrZazB1u.zip) (12.8 KB)

What am I doing wrong?

Thank you very much,  
Joe

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [November 27, 2024, 2:43am UTC](https://forum.arduino.cc/t/help-with-compiler-errors/1326277/2 "2024-11-27T02:43:53Z")

</div>

> [@lindula](#):
>
> #include "HCSR04.h"

- Try:  
#include \<HCSR04.h\>

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [November 27, 2024, 3:28am UTC](https://forum.arduino.cc/t/help-with-compiler-errors/1326277/3 "2024-11-27T03:28:45Z")

</div>

Your class is called _HCSR04Sensor_, not _HCSR04_.

Further the constructor for that class does not take arguments.

> [@LarryD](#):
>
> Try:  
> #include \<HCSR04.h\>

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

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [November 27, 2024, 3:45am UTC](https://forum.arduino.cc/t/help-with-compiler-errors/1326277/4 "2024-11-27T03:45:27Z")

</div>

> [@sterretje](#):
>
> Using your approach will ignore that copy

- I never remember “ ” vs \< \>

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 26, 2025, 3:46am UTC](https://forum.arduino.cc/t/help-with-compiler-errors/1326277/5 "2025-05-26T03:46:17Z")

</div>

Closed on May 26, 2025, 3:46am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
