Ciao a tutti.
Non è la prima volta che lo faccio ma questa volta mi fa un comportamento strano.
Devo leggere 3 input digitali ma quando ne metto uno alto se ne mette anche un altro.
Dove sbaglio?
Sembrerebbe che me lo fa solo col pin 9, mi dice che è acceso anche il 10.
Se al posto del 9 imposto il 12 funziona regolarmente.
Anche se imposto 5/6/7 com pin tutto ok.
Problemi con la scheda?
Questo il codice:
int a = 8;
int b = 9;
int c = 10;
int aVal = LOW;
int bVal = LOW;
int cVal = LOW;
int general = 13;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Pronti");
pinMode(a, INPUT);
pinMode(b, INPUT);
pinMode(c, INPUT);
pinMode(general, OUTPUT);
digitalWrite(general, LOW); // Spengo il led L sulla scheda
}
void loop() // run over and over
{
aVal = digitalRead(a); // read input value
bVal = digitalRead(b); // read input value
cVal = digitalRead(c); // read input value
if (aVal == HIGH) { // check if the input is HIGH (button released)
Serial.write("a accesa\n\r");
}
else {
Serial.write("a spenta\n\r");
}
if (bVal == HIGH) { // check if the input is HIGH (button released)
Serial.write("b accesa\n\r");
}
else {
Serial.write("b spenta\n\r");
}
if (cVal == HIGH) { // check if the input is HIGH (button released)
Serial.write("c acceso\n\r");
}
else {
Serial.write("c spento\n\r");
}
delay(1000);
}