output getting HIGH for no reason

Hello ,
for some reason digital 10 and 3 getting HIGH .
first I thought there is a problem with my code ,so I upload the bare minimal code:

void setup() {
  //empty
}

void loop() {
  //empty
  
}

and still I get high at the output
why is it?
nothing is connect to the SparkFun PRo-Ethernet
just the usb to the computer and a LED to digital 3\10 (with a a resistor of 220 Oham )

please help .
Thanks ,

I get high for no reason. :slight_smile:

But how are the LEDs connected? If they are connected anode to +5v, and cathode to the pin through the resistor, then the pin will show HIGH because it is being pulled up by the LED current.

If your sketch is empty, how do you know the pins read as a HIGH?

no 5v
only :
digital out 3 -->resistor -->anode --cathode -->GND

and I know the output is HIGH , because I check it with a voltmeter
I can See all the digital outputs are 0v and only 3 and 10 getting ~4V

Ahh, so you measured a voltage. That's different from a HIGH.

Is the LED lighting up? What is the voltage you measure between the LED and resistor?

and I know the output is HIGH , because I check it with a voltmeter

On reset all the pins get set to inputs.
What you are seeing is the input floating high. This is normal.
See:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Is this the schematic?

I'm not familiar with that device, but it appears the w5100 may be connected to those pins. Maybe it is it using pullp resistors to keep those two lines (#CS and INT) HIGH?

I think the pins would not float HIGH as inputs in this case. If connected like the OP described above, the LEDs should draw enough leakage current to keep the inputs LOW with no other source of current.

but something is still not good

I have disconnected every thing (again)
and all I have is a wire that goes out from the 5V (in the SparkFun Pro-Ethernet)
and I touch a different Digital Output every time
and when I touch digital out 4 , also 5,6,7 is getting high

this is the code I wrote:

#include <Ethernet.h>
#include <SPI.h>
#include "Wire.h"
#define DS1307_ADDRESS 0x68

int EnPIR=2;
int ManualRED=3; 
int ManualGREEN=4;
int PIRdirection=5
int rightPIR=6;
int leftPIR=7;
int RedLED=9;
int GreenLED=10;
void setup() {
 
  Serial.begin(9600);
  pinMode(EnPIR,INPUT);
  pinMode(ManualGREEN,INPUT);
  pinMode(ManualRED,INPUT);
  pinMode(PIRdirection,INPUT);
  pinMode(rightPIR,INPUT);
  pinMode(leftPIR,INPUT);
  pinMode(RedLED,OUTPUT);
  pinMode(GreenLED,OUTPUT);
 

  delay(2000);

  Serial.print("Please Wait - calibrating sensor ");
  
  for(int i = 0; i < 8; i++)
  {
    Serial.print(".");
    delay(1000);
  }
  Serial.println(" done");
  Serial.println("SENSOR IS NOW ACTIE");
  delay(50);

}

void loop() {
  // put your main code here, to run repeatedly: 
   Serial.print("digout2=");
  Serial.println(digitalRead(EnPIR));
  Serial.print("digout3=");
  Serial.println(digitalRead(ManualRED));
  Serial.print("digout4=");
  Serial.println(digitalRead(ManualGREEN));
  Serial.print("digout5=");
  Serial.println(digitalRead(PIRdirection));
  Serial.print("digout6=");
  Serial.println(digitalRead(rightPIR));
  Serial.print("digout7=");
  Serial.println(digitalRead(leftPIR));
  Serial.print("digout9=");
  Serial.println(digitalRead(RedLED));
  Serial.print("digout10=");
  Serial.println(digitalRead(GreenLED));

  delay(2000);


}

but there isn't a Short circuit.

help?

Thanks ,

What part of floating inputs do you not understand? This is normal behavoure for unconnected inputs.

output getting HIGH for no reason

void setup() {
  //empty
}

void loop() {
  //empty
  
}

All pins default to inputs so your basic premise is wrong. You can't say "output high for no reason" if they are inputs.

but something is still not good

It will be better if you make your outputs, outputs.

Of-course the led get an output at the setup ()
maybe I don't see a simple\stupid thing , and another pair of eyes will see
let me show you (in general....) how my code is built:

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

int RedLED=9; //digital ourput LED
int GreenLED=10;//digital ourput LED

void setup ()
{
  pinMode(GreenLED,OUTPUT);
  pinMode(emptyLED,OUTPUT);
 digitalWrite(RedLED,HIGH);
  digitalWrite(GreenLED,HIGH);
delay(5000);
digitalWrite(RedLED,LOW);
  digitalWrite(GreenLED,LOW);
}

void loop()
{

 digitalWrite(GreenLED,LOW);//this I have added and still the green led is on!
d=program();
if (d==1)
serial.print(d);
{digitalWrite(GreenLED,HIGH);
digitalWrite(RedLED,LOW);

}
else 
{
serial.print(d);
  digitalWrite(GreenLED,LOW);
digitalWrite(RedLED,HIGH);
}


}//end of loop

I print the "d" to and I can see that it 1 and also that it is 0 - so the sub program works fine.
the red led is working as plan.

also I'm adding a scheme of my circuit

hope its helps ,

Thanks ,

sketch_jul05b.cpp: In function 'void setup()':
sketch_jul05b:10: error: 'emptyLED' was not declared in this scope
sketch_jul05b.cpp: In function 'void loop()':
sketch_jul05b:22: error: 'd' was not declared in this scope
sketch_jul05b:22: error: 'program' was not declared in this scope
sketch_jul05b:24: error: 'serial' was not declared in this scope
sketch_jul05b:29: error: 'else' without a previous 'if'
sketch_jul05b:31: error: 'serial' was not declared in this scope

Post code that actually compiles, and demonstrates the problem. Then we can talk.

david1234:
let me show you (in general....) how my code is built:

Posting code that sort-of shows what you have done is useless. Adding a single semicolon can make huge difference. You have to post the actual code.

david1234:
Of-course the led get an output at the setup ()

david1234:
first I thought there is a problem with my code ,so I upload the bare minimal code:

void setup() {

//empty
}

void loop() {
  //empty
 
}

Where do you set the LED to output?

I'm trying to send you the code but it's too long
so
this is en example of my code :

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

int RedLED=9; //digital ourput LED
int GreenLED=10;//digital ourput LED
int d;
int digiIN=5;
void setup ()
{
  pinMode(GreenLED,OUTPUT);
  pinMode(DIGIin,INPUT);
  digitalWrite(RedLED,HIGH);
  digitalWrite(GreenLED,HIGH);
  delay(5000);
  digitalWrite(RedLED,LOW);
  digitalWrite(GreenLED,LOW);
}

void loop()
{

  digitalWrite(GreenLED,LOW);//this I have added and still the green led is on!
  d=program();
  if (d==1)
    serial.print(d);
  {
    digitalWrite(GreenLED,HIGH);
    digitalWrite(RedLED,LOW);

  }
  else 
  {
    serial.print(d);
    digitalWrite(GreenLED,LOW);
    digitalWrite(RedLED,HIGH);
  }


}//end of loop 

int program()
{
  if (digitalRead(digiIN==0));
  {
    d=0;
  }
  else 
  {
    if (digitalRead(digiIN==1))
    {
      d=1;
    }
  }

}

Why no Serial.begin in setup?

You can attach code you know. Click on Additional Options and then you can upload the code.

o.k.

Here,

  if (digitalRead(digiIN==0));

This code is just riddled with problems. It is assigning a value to digiIN, then reading from some pin based on the true/false result of that assignment. Then, it does nothing with the result of the read.

david1234:
I'm trying to send you the code but it's too long

If you can't reproduce the problem with a SHORT sketch, then you aren't trying. It is unnecessary and counterproductive to post a huge sketch when the problem is in only one small area. Write the smallest simplest sketch you can that demonstrates the problem. Confirm that it does compile and run and demonstrate the problem, then post that.