Hi there,
I am working on a project over Arduino Mega 2560, just to read the pins status high and low with the help of some switches.
But the pins are floating. On Arduino Forum, i found, we can use internal pullup resistors or external pullup/down resistors to stop the interference.
Pins (22 to 50) are used with digitalRead().
But still observing the same issue.
in pullup, Serial monitor goes freeze. Then i have to unpulg and plug again the board to use it.
in external pull down, still pins are floating. (resistance values used in between 2K to 6K).
Please Help me in this, how to remove the interference.
hemants:
Please Help me in this, how to remove the interference.
PaulS:
Common sense, realistic expectations, and proper code.
@OP 1. Remove all wiring from these IO pins: 22 - 50. 2. Press RESET Button of Arduino. 3. Use DVM; measure and record the voltage at DPin-22. 4. Connect a pull-down resistor (2.2k/4.7K) with DPin-22. 5. Use DVM; measure and record the voltage at DPin-22. The voltage should be around ~=0V. If not, it must be below 0.9V and not fluctuating.
6. Connect one end of a PUSH with DPin-22. Connect the other end of the PUSH switch with 5V. Connect a DVM with DPin-22. Press the switch. The DVM should read ~5V. If not, it must be above 4.2V and not fluactuating.
7. Similarly, deal with DPin-23.
Is there any floating condition on DPin-22 or DPin-23?
i tried as per your feedback but no floating condition of pin is there individually.
If i am turning any pin LOW to HIGH, then pins are floating randomly. Its not like that its floating without any interference. for eg. if i am switching pin 23 LOW to HIGH then sometimes pin 27, sometimes pin 43 etc are floating but not the pin 23, as its already HIGH.
I am new to arduino.
As per the forum and guide, i have connected the circuit as per attachment, by pull up resistors to control the floating of the pins
But still having the same floating pins issue whenever i switch on/off any of the switch the other pin shows the float issue.
Connected around 17 switches all as per the image to arduino pins from 22 to 38.
Code used is as per following:
int prevPinVal[17];
void setup() {
// put your setup code here, to run once:
for(int i=22; i<=38;i++)
{
pinMode(i, INPUT);
prevPinVal[i-22] = digitalRead(i);
}
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int pinVal;
for(int i=22; i<=38; i++)
{
pinVal = digitalRead(i);
if(pinVal != prevPinVal[i-22])
{
Serial.print("<");
Serial.print(i);
Serial.print(",");
Serial.print(pinVal);
Serial.print(">");
}
prevPinVal[i-22] = pinVal;
}
Serial.println("");
delay(1000);
}
Moderator edit: </mark> <mark>[code]</mark> <mark>