Hallo noch einmal,
zum Aufbau:
Ich habe den Arduino Uno, und darauf das Rev3 Motor Shield. An dem Motorshield ist das Keypad Shield mit dem 16x2 Display angeschlossen (LINK).
Als Ausgabe bekomme ich leider immer nur:
"LCD Key Shield"
"Press Key:Right"
Obwohl ich noch gar nichts gedrückt habe, bzw auch andere Tasten drücke.
Code:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("LCD Key Shield");
lcd.setCursor(0,1);
lcd.print("Press Key:");
Serial.begin(9600);
}
void loop() {
int x;
x = analogRead (0);
lcd.setCursor(10,1);
if (x < 60) {
lcd.print ("Right ");
}
else if (x < 200) {
lcd.print ("Up ");
}
else if (x < 400){
lcd.print ("Down ");
}
else if (x < 600){
lcd.print ("Left ");
}
else if (x < 800){
lcd.print ("Select");
}
Serial.println(x);
}
Verhält sich die Ausgabe auch so, wenn das MotorShield nicht "dazwischengeschaltet" ist?
Nicht, daß der CurrentSensePin (A0) von diesem die AnalogWerte irgendwie verfälscht? (Mutmaßung)
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("DisplayShield1");
lcd.setCursor(0,1);
lcd.print("Press Key:");
Serial.begin(9600);
}
void loop() {
int x;
x = analogRead (0);
lcd.setCursor(10,1);
if (x < 60) {
lcd.print ("Right ");
}
else if (x < 200) {
lcd.print ("Up ");
}
else if (x < 400){
lcd.print ("Down ");
}
else if (x < 600){
lcd.print ("Left ");
}
else if (x < 800){
lcd.print ("Select");
}
Serial.println(x);
}
Werte:
keine taste: 219/220
Select:219/220
Left:219/220
Down:219/220
Up:219/220
Right:101
Rst:219/220
Es kann doch nicht sein das alle Knöpfe Kaputt sind ?
passt ihmo nicht ansatzweise zum Schaltbild. Wenn du die Möglichkeit hast, schick das Drumm zurück.
Kauf dir ein schönes Tastenboard (oder noch schönere Tasten )
Kauf dir ein I2C LCD-Display. Langfristig willst sowieso nicht mit dem 4Bit Modus rumeiern.
noch ein Ansatz: hat vielleicht einer der Taster einen Kurzschluss (ist immer "gedrückt")? Laut Schaltbild tippe ich auf den "up"-Taster... Das würde auch erklären, wieso sich nur bei "right"-gedrückt etwas ändert..