20-01-2017, 00:16
no czuję się jak debil już, myśląc ile ścisłych umysłów tu siedzi.. ale jak widać nie jest to mi pisane
próbuję ustawić na przyciśku 3 w keypad 4x1 zwyłky, najprostszy switch on/off,
czyli pierwsze naciśniecię Serial.println("pierwsza"); , drugie Serial.println("druga");
czy ktoś pomoże debilowi co robię źle?
próbuję ustawić na przyciśku 3 w keypad 4x1 zwyłky, najprostszy switch on/off,
czyli pierwsze naciśniecię Serial.println("pierwsza"); , drugie Serial.println("druga");
czy ktoś pomoże debilowi co robię źle?
Kod:
const int buttonPin[] = {9, 10, 11, 12};
// const int ledPin = 13;
int buttonState = 0;
int ledState = -1;
long lastDebounceTime = 0;
long debounceDelay = 50;
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
// pinMode(ledPin, OUTPUT);
for (int x = 0; x < 2; x++)
{
pinMode(buttonPin[x], INPUT_PULLUP);
}
}
void loop() {
// put your main code here, to run repeatedly:
for (int x = 0; x < 2; x++)
{
buttonState = digitalRead(buttonPin[x]);
if (buttonState == HIGH && (ledState < 0))
{ delay(500);
Serial.println("pierwsza");
ledState = -ledState;
lastDebounceTime = millis();
}
else if (buttonState == HIGH && (ledState > 0)) {
{ delay(500);
Serial.println("druga");
ledState = -ledState;
lastDebounceTime = millis();
}
}
}
}