Hi!
I want the arduino only to send data when necesarry instead of that annoying stream of 0’s and 1’s if creating a switch.
My test is a very simple one but i can’t get it to work. I have the pin 13 as an input. So when the input is in LOW, the arduino sends a 0 only once. It doesn’t send anything else unless the switch is turned to HIGH. In that case, the arduino sends a 1 only once. Until the switch is turned to LOW again.
I hope you catch the idea.
The proble i have is that suddenly i get lines of serial output like “0101100”.
Here’s the code:
int actualvalue;
int prevvalue;
void setup (){
Serial.begin (9600);
pinMode (13, INPUT);
prevvalue = digitalRead (13);
}
void loop () {
actualvalue = digitalRead (13);
if (valactual != prevvalue) {
Serial.print (actualvalue);
prevvalue = actualvalue;
}
}