Für das Keypad Shielt währe das example was man auf den meisten Bildern sieht nett (wo man nen Text sieht und wo angezeigt wird welche Taste man gedrückt hat) und für den HY-SRF05 vll eines wo man die Entfernung als wert zurückbekommt (den man eventuel auf dem Display ausgeben kann).
Ich hab den Link zum KeyPad Shield noch nachträglich im Startpost eingetragen.
Die Fehlermeldung weiß ich leider nicht mehr genau.
Und was meinst du mit Version?
#define SONAR_TRIGGER_PIN 2 // HC-SRF05 Trigger Pin -> Ardunio digital Pin 2
#define SONAR_ECHO_PIN 3 // HC-SRF05 Echo Pin -> Arduino digital Pin 3
unsigned int measure_distance()
{
// send the sensor a 10 microsecond pulse:
digitalWrite(SONAR_TRIGGER_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(SONAR_TRIGGER_PIN, LOW);
// wait for the pulse to return. The pulse
// goes from low to HIGH to low, so we specify
// that we want a HIGH-going pulse below:
unsigned long pulse_length = pulseIn(SONAR_ECHO_PIN, HIGH);
// can't send more than one pulse each 50 ms or
// we could get interference
delay(50);
// convert to cm and return
return( (unsigned int) (pulse_length / 58) );
}
void setup()
{
pinMode(SONAR_TRIGGER_PIN, OUTPUT);
pinMode(SONAR_ECHO_PIN, INPUT);
Serial.begin(9600);
}
void loop()
{
unsigned int current_distance = measure_distance();
Serial.print(current_distance);
Serial.println(" cm");
delay(150);
}
Danke, das example des HY-SRF05 funktioniert (mehr oder oder weniger, es zeigt mir ne total falsche entfernung an....)
Ich hab mal auf der Verlinkten Seite geschaut, ja es sollte dieses KeyPad Shield sein.
Ich hab mal das erste Example(von hier) getestet und folgenden Error bekommen:
In file included from C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Arduino.h:191,
from C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\libraries\LCD4Bit_mod\LCD4Bit_mod.cpp:31:
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:116: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, const char*)' conflicts with
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:115: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:117: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, char)' conflicts with
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:116: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:118: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:117: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, char)' here
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:119: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:118: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' here
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:120: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' conflicts with
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:119: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, int)' here
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:121: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long int)' conflicts with
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:120: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' here
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:122: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long unsigned int)' conflicts with
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/WString.h:121: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, long int)' here
In file included from C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\libraries\LCD4Bit_mod\LCD4Bit_mod.cpp:31:
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Arduino.h:195: error: declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Arduino.h:194: error: previous declaration 'uint16_t makeWord(uint16_t)' here
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Arduino.h:205: error: declaration of C function 'long int random(long int)' conflicts with
c:/users/freedomhacker/downloads/arduino-1.0-windows/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:504: error: previous declaration 'long int random()' here
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Arduino.h:206: error: declaration of C function 'long int random(long int, long int)' conflicts with
C:\Users\FreedomHacker\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Arduino.h:205: error: previous declaration 'long int random(long int)' here
Nimm doch mal das zweite Beispiel. Da wird die LCD-Library genutzt, die in der IDE 1.0 enthalten ist. Damit sollte es auch keine Fehlermeldungen geben.
so hab das Problem gelöst:
Es lag daran das die libs wahrscheinlich veraltet waren, hab sie neu geladen und nun gehts
Wiedermal danke für die nette Hilfe :)