Hello! I fixed the code with the "while (Serial.available() > 0)" and eliminating all the delays but still doesn't work. Prints continuosly one of the values even if the pins are free.
The electronic circuit is tested and working.
We are working on a "Makey Makey-like" arduino(Uno) with three touch controller (simple wires) trough digital pins.
here the code:
int inPin2 = 3 ;
int inPin3 = 4 ;
int inPin4 = 7 ;
int digitalValue1;
int digitalValue2;
int digitalValue3;
void setup()
{
Serial.begin(9600);
}
void loop() {
while (Serial.available() > 0)
int digitalValue1 = digitalRead(inPin2);
if (digitalValue1 == HIGH){
Serial.write("A");
}
int digitalValue2 = digitalRead(inPin3);
if (digitalValue2 == HIGH) {
Serial.write ("B");
}
int digitalValue3 = digitalRead(inPin4);
if (digitalValue3 == HIGH) {
Serial.write("C");
}
}
free= taking ALL the wires off from the arduino (pins, ground,voltage) the shield alone (only with the usb connected) still sends a same value
[/quote]
So in other words, the pin is floating with an undefined state.
Arrch:
So in other words, the pin is coating with an undefined state.
Exactly! and seems there is no way to get rid of this value coming from the buffer even when the rest of the sketch runs correctly and the arduino gets the right touch on/off values for the other pins
Arrch:
So in other words, the pin is coating with an undefined state.
Exactly! and seems there is no way to get rid of this value coming from the buffer even when the rest of the sketch runs correctly and the arduino gets the right touch on/off values for the other pins
If the pin is undefined the results will be undefined.
JackMilan:
I've done what you said but it still blocks with the PULL_UP mode
The code you just posted does not enable the input pull-up resistors. Without any internal pullup and nothing connected externally the inputs will be floating and can return arbitrary values when you read them.
I attach the wires to my arduino and load my sketch. Then i print only High Values (it's like getting an ON, if someone touchs). But insted of On i have "A" "B" "C".
I treat everything like three pushbuttons. I use the Pull down resistor mode here:
BUT ------> this works fine only for a while and then blocks, the light on TX became non stop RED and on my monitor i can see printing "B" without stopping even if nobody touches the wire. Even worse, if i get off the wires from my arduino (all) and reload the same sketch the problem remains. The "B" still prints.
Without any logic goes away after many tries to reload the sketch. That's why I think may be a buffering issue, need to clean the buffer every now and then. Hope that
while (Serial.available() > 0)
incomingByte =Serial.read();
As others have said, it sounds like floating inputs. Experienced this with trimpots and switches that were not forming good connections to jumper wires.