Ethernet Shield

Greetings, it's me again, just to make it clear again , english is not my first language , I apologise if there is any mistake.
Let's get to the point.
I did this program and it seems to be working fine. however. once I tryed to add the ethernet shield code. it just do not show the web page.
I tryed to make it as clean as possible, and not gonne lie is based on examples that I found on internet.
Hope that you could tell me if there is something wrong with the code.
(The code is a bit long so I attached it )
I also found this code to test my ethernet shield , if it prints de ip the shield is working, and apparently it is working , but I'm not sure if it is true.

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,30);

void setup() {
  Serial.begin(9600);

  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.println("Starting w5100");
  Ethernet.begin(mac,ip);

  Serial.println(Ethernet.localIP());
}

void loop() {
}

I'm not a programmer, but I really need to get this done (or maybe I'm now , but a really novice one lol )

Thanks for reading.

Pruebas.ino (9.48 KB)

it will run and print the IP address even without the shield.
see the examples of the current version of the Ethernet library

it is the most common habit of newbees to just add a complex code by copy & paste maybe adapt variable-names to their project and then - it does not work.

You should find a demo-code that is written for your ethernet-shield. Testing if the ethernet-shield works with this demo-code.

Then do a simple and small change like adding a single variable to the demo-code testing if the changed demo-code works

If Yes add the demo-code to your main program. Testing again if the http-functionality is working.

if it works add a small change - test
if it works add a small change - test
if it works add a small change - test
....
best regards Stefan

if it prints de ip the shield is working, and apparently it is working , but I'm not sure if it is true.

Well, if you get an IP address, why not enter it in your browser and check if your server is working? So - if you encounter a problem with your code - clearly state what problem you have.

As Juraj already stated, start with the Arduino IDE Example
Ethernet | WebServer
This example MUST Work when you are using an Arduino UNO.

If you can confirm, we can come up with more proposals.

    Serial.begin(9600);//serial port speed

  //People counter
    pinMode(0, INPUT); //Infrared  In
    pinMode(1, INPUT); //Infrared  Out

On the Arduino UNO, Pin 0 and Pin 1 are the Serial pins! You can't use them for both. Note: You can use A0 through A5 for digital I/O if you are running low on digital pins.

    pinMode(4, OUTPUT); //Ultrasonic trigger

WARNING: If you have an SD card in the slot on the Ethernet Shield, setting Pin 4 to LOW will put that SD card on the SPI bus used by the Ethernet chip. Should be OK if you don't have an SD card in the slot.

    if((distanciaT>5)&&(ciclo==0)){
    if((distanciaT < 5 )&&(36.5<temperatura)&&(temperatura<40))

WARNING: pulseIn() will return 0 if there is no pulse. This happens if there is nothing close enough to produce a readable echo. You may want to consider 0 to be greater than 5.

sorry for the late reply I got a bit busy :confused: .
It is working now , aparrently there was an error with the ethernet that I was using.
Juraj , I used a simple program that I found and it is working thanks for that , I didn't know arduino had many examples.
StefanL38 , I'll start to do that , seems better than just writte it all at once.
noiasca , that's what I did , but it wasn't working (a problem with the ethernet cable) , but now it is working.
jhonwasser :
I didn't know that , guess I'm going to have to do some little changes , thanks for pointing that.
I'm not using a SD card , still not sure If I will need one.
oh , so then I'll add that greater than 0 condition

Thank you guys for helping me :slight_smile: