Hi there, I'm trying to lighten 10 LEDs one by one according to the number of touch of 2 copper foils. When these two copper foils touched at the first time, the first LED lightens. When these two copper foils touched at the second time, the first two LEDs lighten. And so on... Until they touched at the tenth time, all of the LEDs lighten. After that, it will start again as a circulation.
I tried to use one copper foil as the conductive sensor, another one is connecting to the ground, but obviously, there is a delay at the serial port. After that, I tried to use two foils as the button, However, this time, there are no numbers jumps at the serial monitor...
In the situation of a button, even though I can get the jumping numbers as what happened in the conductive sensor case, I can't transfer a heap of numbers into counting. How can I know when these numbers appear, I should count for one more?
I really have no idea how to make it and I have a quite close deadline. Could I get some hints for that? Any advice is appreciated.
void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
Serial.print(1);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
Serial.print(2);
}
}