Hi, I'm not an expert on Arduino and I'm facing an issue I can't resolve by googling.
I have a HC-SR04 Ultrasonic module and have developed a couple of programs that are working properly.
Now I'm trying to code a new program that uses this module and library at the same time that the Ethernet library, and everytime I call "ultrasonic.Ranging(CM);" it returns "0".
I tried to reduce the code to the minimum to detect what's going on, and figure out that, in the following code, commenting the line "webserver.begin();" everything works as expected, but with that line, I get the "0" response.
Does anyone faced this or have any clue about the reason and how to solve it?
Best Regards.
P.S.: The Ultrasonic library I'm using is: GitHub - hemalchevli/ultrasonic-library: Arduino Library to use with the ultrasonic sensor HC-SR04
#include "Ultrasonic.h"
Ultrasonic ultrasonic(10,11);
#include "SPI.h" // new include
#include "Ethernet.h"
#include "WebServer.h"
#define VERSION_STRING "0.1"
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
static uint8_t ip[] = { 172, 16, 20, 251 };
#define PREFIX ""
WebServer webserver(PREFIX, 80);
void setup()
{
webserver.begin();
Serial.begin(9600);
}
void loop()
{
int distance;
distance = ultrasonic.Ranging(CM);
Serial.print("distance:");
Serial.print(distance);
Serial.print("\n");
}