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 )
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.
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.
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);
}
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.
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.
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;
}
}
}
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.