Hilfe für 128x64 lcd, 4x4 keypad und LED Matrix projekt gesucht

Hallo zusamman,

ich brauche bitte hilfe bei meinem projekt.

Wie der Titel schon sagt ist es eine Led Matrix mit einem Keypad und einem LCD Display. Zudem habe ich potis zum regeln der Helligkeit, Rot, Grün und Blau. Also eigentlich zum farbe mischen und so.....

Ich brauche bitte hilfe bei folgenden Dingen:

/////////////////////////////// GELÖST ////////////////////////

  1. Wie verhindere ich das "ruckeln/zucken" von Potentiometern?
    Es ist so das die einfach ihren eingestelten wert nicht konstant halten sondern immer einen wert rauf oder runter hin und her schwanken. Was natürlich ein flackern der LED Matrix erzeugt-
    //////////////////////////////// GELÖST /////////////////////
  2. Ich möchte gerne das mir auf der zweiten seite (void Draw 2) die zahl oder Buchstabe vom Keypad, wenn ich es drücke, mit angezeigt wird.
    Da komme ich nicht weiter. Ich weiß nicht was ich machen muss damit ich " if (keyin != NO_KEY) " in das void draw hinenbringe. Weil so bekomme ich ja immer die fehlermeldung :
    'keyin' was not declared in this scope
#define SwitchPIN 8
#include "U8glib.h"
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <SPI.h>

#include <Keypad.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 9




TinyGPSPlus gps;


OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);


U8GLIB_ST7920_128X64 u8g(5, 6, 7, U8G_PIN_NONE);



float TargetGpsLAT = 48.3581916;  // Coordinates EIFFEL_TOWER in France
float TargetGpsLON = 12.5119766;
bool DistanceInKM = false;
bool Button1Pressed = false;
double Distance = 0;
double courseToT = 0;


#include "U8glib.h"

#define botao 24
int estado_botao = 0;
int pot1        = A0;
int pot2        = A1;
int pot3        = A2;
int pot4        = A3;
int pot5        = A4;
int pot6        = A5;

int del1        = 0;
int del2        = 0;
int bright      = 0;
int rot         = 0;
int gruen       = 0;
int blau        = 0;

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns

char keys[ROWS][COLS] = { // Define the Keymap
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {37, 39, 43, 45};
byte colPins[COLS] = {47, 49, 51, 53};
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );// Create the Keypad
Adafruit_NeoPixel strip = Adafruit_NeoPixel(256, PIN, NEO_GRB + NEO_KHZ800);

void draw1() {


  if (gps.altitude.isValid() )
  {

    if (gps.altitude.isUpdated() || gps.satellites.isUpdated() || gps.course.isUpdated() )
    {

      u8g.setFont(u8g_font_fixed_v0);
      u8g.setPrintPos(75, 20);
      u8g.print("Alt:");
      u8g.setPrintPos(100, 20);
      u8g.print(gps.altitude.meters());
      u8g.setPrintPos(95, 10);
      u8g.print("S:");
      u8g.setPrintPos(110, 10);
      u8g.print(gps.satellites.value());
      u8g.setPrintPos(42, 20);
      u8g.print("C:");
      u8g.setPrintPos(52, 20);
      u8g.print(gps.course.deg()); // Course in degrees (double)
    }
  }
  else
  {

    u8g.setFont(u8g_font_fixed_v0);
    u8g.setPrintPos(75, 20);
    u8g.print("Alt:");
    u8g.setPrintPos(100, 20);
    u8g.print("000");

    u8g.setPrintPos(42, 20);
    u8g.print("C:");
    u8g.setPrintPos(52, 20);
    u8g.print("000"); // Course in degrees (double)
    //u8g.print("No valid Data");
  }

  if (gps.location.isValid())
  {
    if (gps.location.isUpdated() || gps.location.isValid())
    {
      u8g.setFont(u8g_font_fixed_v0);
      u8g.setPrintPos(15, 30);
      u8g.print("POS. Aktuel:");
      u8g.setPrintPos(1, 40);
      u8g.print("BG:");
      u8g.setPrintPos(20, 40);
      u8g.print(gps.location.lat(), 4); // Raw latitude

      u8g.setPrintPos(68, 40);
      u8g.print("LG:");
      u8g.setPrintPos(86, 40);
      u8g.print(gps.location.lng(), 4); // Raw longitude
      u8g.setPrintPos(5, 50);
      u8g.print("Start:");
    }
  }
  else
  {
    u8g.setFont(u8g_font_fixed_v0);
    u8g.setPrintPos(35, 30);
    u8g.print("POS. Aktuel:");
    u8g.setPrintPos(1, 40);
    u8g.print("BG:");
    u8g.setPrintPos(20, 40);
    u8g.print("00.0000"); // Raw latitude

    u8g.setPrintPos(68, 40);
    u8g.print("LG:");
    u8g.setPrintPos(86, 40);
    u8g.print("00.0000"); // Raw longitude

    u8g.setPrintPos(5, 50);
    u8g.print("Start:");
  }
  if (gps.date.isValid() & gps.date.isValid())
  {
    u8g.setFont(u8g_font_fixed_v0);
    u8g.setPrintPos(5, 10);
    u8g.print(gps.date.day());
    u8g.setPrintPos(10, 10);
    u8g.print(".");
    u8g.setPrintPos(15, 10);
    u8g.print(gps.date.month());
    u8g.setPrintPos(20, 10);
    u8g.print(".");
    u8g.setPrintPos(25, 10);
    u8g.print(gps.date.year());

    u8g.setPrintPos(55, 10);
    u8g.print(gps.time.hour() + 2);
    u8g.setPrintPos(70, 10);
    u8g.print(":");
    u8g.setPrintPos(75, 10);
    u8g.print(gps.time.minute());
  }
  else
  {
    u8g.setFont(u8g_font_fixed_v0);
    u8g.setPrintPos(10, 10);
    u8g.print("No valid Timestamp  ");
  }

  if (gps.speed.isValid())
  {
    u8g.setFont(u8g_font_fixed_v0);
    u8g.setPrintPos(5, 20);
    u8g.print(gps.speed.kmph());


  } else
  {
    u8g.setFont(u8g_font_fixed_v0);
    u8g.setPrintPos(1, 20);
    u8g.print("GS:");
    u8g.setPrintPos(20, 20);
    u8g.print("00");

  }

  if (TargetGpsLAT < 90 & TargetGpsLON < 180  )
  {

    u8g.setFont(u8g_font_fixed_v0);

    u8g.setPrintPos(1, 60);
    u8g.print("BG:");
    u8g.setPrintPos(20, 60);
    u8g.print(TargetGpsLAT, 4); // Raw latitude

    u8g.setPrintPos(68, 60);
    u8g.print("LG:");
    u8g.setPrintPos(86, 60);
    u8g.print(TargetGpsLON, 4); // Raw longitude

  } else
  {
    u8g.setFont(u8g_font_fixed_v0);

    u8g.setPrintPos(1, 60);
    u8g.print("00000");
  }

  if (gps.location.isValid() & TargetGpsLAT < 90 & TargetGpsLON < 180 )
  {
    DistanceInKM = false;
    Distance = gps.distanceBetween(gps.location.lat(), gps.location.lng(), TargetGpsLAT, TargetGpsLON);
    courseToT = gps.courseTo(gps.location.lat(), gps.location.lng(), TargetGpsLAT, TargetGpsLON);
    if (Distance > 1000)
    {
      Distance = Distance / 1000;
      DistanceInKM = true;
    }
    u8g.setFont(u8g_font_fixed_v0);
    u8g.setPrintPos(50, 50);
    u8g.print("dst:");
    u8g.setPrintPos(75, 50);
    u8g.print(Distance);

    if (DistanceInKM)  {
      u8g.print("km ");
    } else {
      u8g.print("m ");
    }

  } else
  {


    u8g.setFont(u8g_font_fixed_v0);

    u8g.setPrintPos(50, 50);
    u8g.print("00000");
  }
  smartdelay(10);
}

void draw2()
{



  u8g.setFont(u8g_font_fixed_v0);
  u8g.setPrintPos(20, 10);
  u8g.print("Matrix info:");
  u8g.setPrintPos(5, 20);
  u8g.print("Temp:");
  u8g.setPrintPos(40, 20);


  u8g.setPrintPos(5, 30);
  u8g.print("Rot:") ;
  u8g.setPrintPos(40, 30);
  u8g.print(rot) ;
  u8g.setPrintPos(65, 30);
  u8g.print("Speed1:") ;
  u8g.setPrintPos(105, 30);
  u8g.print(del1) ;
  u8g.setPrintPos(5, 40);
  u8g.print("Blau:") ;
  u8g.setPrintPos(40, 40);
  u8g.print(blau) ;
  u8g.setPrintPos(65, 40);
  u8g.print("Speed2:") ;
  u8g.setPrintPos(105, 40);
  u8g.print(del2) ;
  u8g.setPrintPos(5, 50);
  u8g.print("Grun:") ;
  u8g.setPrintPos(40, 50);
  u8g.print(gruen) ;
  u8g.setPrintPos(5, 60);
  u8g.print("Hell:") ;
  u8g.setPrintPos(40, 60);
  u8g.print(bright) ;


  if (keyin != NO_KEY)
    u8g.setPrintPos(65, 105);
  u8g.print(keyIn);
  else
  { u8g.setPrintPos(65, 105);
    u8g.print(" -- " ) ;
  }


  smartdelay(10);

}

void draw3()
{
  u8g.setFont(u8g_font_fixed_v0);

  u8g.setPrintPos(5, 20);
  u8g.print("Temp:");
  u8g.setPrintPos(40, 20);
  u8g.print( sensors.getTempCByIndex(0));
  smartdelay(10);
}


void setup(void) {

  sensors.begin();


  if ( u8g.getMode() == U8G_MODE_R3G3B2 )
    u8g.setColorIndex(255);     // white
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
    u8g.setColorIndex(3);         // max intensity
  else if ( u8g.getMode() == U8G_MODE_BW )
    u8g.setColorIndex(1);         // pixel on

  pinMode(SwitchPIN, INPUT_PULLUP); // Setzt den Digitalpin 13 als Outputpin
  pinMode(botao, INPUT_PULLUP);
  strip.begin();
  strip.show();

  smartdelay(1);
  pinMode(12, OUTPUT);
  Serial.begin(57600); // connect serial
  Serial.println("The GPS Received Signal:");
  Serial1.begin(9600); // connect gps sensor

}

void loop(void) {
  digitalWrite(12, HIGH);
  bright    = analogRead(pot5); // wir legen fest, dass die Variable pot1_wert für uns den Wert des Potis speichert
  bright    = map(bright, 0, 1023, 0, 240);
  del1      = analogRead(pot1);
  del2      = analogRead(pot6);
  rot       = analogRead(pot4);
  rot       = map(rot, 0, 1023, 0, 255);
  gruen     = analogRead(pot2);
  gruen     = map(gruen, 0, 1023, 0, 255);
  blau      = analogRead(pot3);
  blau      = map(blau, 0, 1023, 0, 255);
  sensors.requestTemperatures();
  float tempC = sensors.getTempCByIndex(0);
  static char key;
  char keyIn = kpd.getKey();
  boolean valor_botao = digitalRead(24);



  if (valor_botao != 1)
  {
    while (digitalRead(24) != 1)
    {
      delay(10);
    }
    // Inverte o estado
    estado_botao++;
    estado_botao %= 3;
  }

  //picture loop
  u8g.firstPage();
  do {
    if (estado_botao == 0)
    {
      draw1();
    }
    if (estado_botao == 1)
    {
      draw2();
    }
    if (estado_botao == 2)
    {
      draw3();
    }
  }
  while ( u8g.nextPage() );
  delay(10);
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  if (keyIn) key = keyIn;

  if (key) // Check for a valid key.
  {
    switch (key)
    {

      case '1':

        {
          strip.fill(strip.Color(0, 0, 255), 8, 8);
          strip.fill(strip.Color(0, 0, 255), 16, 8);
          strip.fill(strip.Color(0, 0, 255), 40, 8);
          strip.fill(strip.Color(0, 0, 255), 48, 8);
     
          strip.setBrightness(bright);
          strip.show();
          
          
          smartdelay(del2);
        }
        break;


      case '2':


        {
          
          strip.setPixelColor(193, (strip.Color(255, 90, 0)));
          strip.setBrightness(bright);
          strip.show();
          smartdelay(del1);
          
          
        }
        break;

      case '3':


        
        strip.setPixelColor(159, (strip.Color(139, 0, 139)));
        strip.setBrightness(bright);
        
        strip.show();
       
        smartdelay(600);

        break;




      case 'A':

       
        strip.setPixelColor(157, (strip.Color(139, 0, 139)));
        strip.setBrightness(bright);
        strip.show();

        smartdelay(del1);
       
        

        break;


      case '4':

        strip.fill(strip.Color(255, 255, 255), 0, 256);
        strip.setBrightness(bright);
        strip.show();

        break;


      case '5':

        strip.fill(strip.Color(rot, gruen, blau), 0, 256);
        strip.setBrightness(bright);
        strip.show();

        break;

      case '6':
        strip.fill(strip.Color(rot, gruen, blau), 0, 256);
        strip.setBrightness(bright);
        strip.show();
        smartdelay(del2);
        strip.clear();
        strip.show();
        smartdelay(del2);
        break;

      //case 'B':
      //break;
      //case '7':
      //case '8':
      //case '9':
      //case 'C':
      //case '*':
      //case '0':
      //case '#':

      case 'D':

        strip.clear();
        strip.show();
        break;


      default:
        Serial.println(key);

    }
  }

  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}





static void smartdelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    if (!(digitalRead(SwitchPIN)))   // read the input pin
    {
      delay(100);   //debouncing
      if (!Button1Pressed)
      {
        Button1Pressed = true;
        TargetGpsLAT = gps.location.lat();
        TargetGpsLON = gps.location.lng();
        u8g.setFont(u8g_font_fixed_v0);
        u8g.setPrintPos(5, 60);
        u8g.print("W:");
        u8g.setPrintPos(10, 60);
        u8g.print(TargetGpsLAT, 4); // Raw longitude in whole degrees
        u8g.setPrintPos(80, 60);
        u8g.print(" L:");
        u8g.setPrintPos(90, 60);
        u8g.print(TargetGpsLON, 4); // Raw longitude in whole degrees
      }
    }  else
    {
      Button1Pressed = false;
    }

    while (Serial1.available())
      gps.encode(Serial1.read());
  } while (millis() - start < ms);
}

Bitte nicht wundern!
Da hängt dann noch ein GPS, ein Temperatur fühler und ein nrf24l01mit dran :slight_smile:
Und der code mit dem nrf24l01 teil ist noch nicht fertig :see_no_evil:

Grüße

Georg

Dann wirf erst mal alles raus, was mit Deiner aktuiellen Frage nichts zu tun hat und zeige dann den angepassten Sketch.
Die Änderung vom Poti nur übernehmen, wenn der Abstand zum alten Wert > 2 (austesten) ist oder auf gute Rotary Encoder wechseln.
Das Andere habe ich nicht verstanden.

Gruß Tommy

Würde ich ja. Hilfst Du dabei?

#define SwitchPIN 8
ist Mist. Pins verändern sich nicht.

const uint8_t switchPin=8;
So auch an diverser anderer Stelle.

Auch hier:
int pot1 = A0;
Das ist ein byte. unveränderlich.

Du willst was rund um Tasten gelöst bekommen. Schmeiss das gps-Zeug raus.
Wenn es zwischendurch drin sein muss, mach ne Dummy-Codezeile dazu.

delay - in jedweder Form ist zu vermeiden.
auch sowas hier //////////[..]

Kürze das mal runter ohne gps.
Und ich sag Dir jetzt schon, das debounce für Dich noch wichtig wird.

Es wird.

(@Tommy56 war schneller..)

So, ich habe jetzt so ziemlich alles was nicht mit der frage zu tun hat rausgenommen.

Zu dem #define SwitchPIN 8 kann ich nicht all zu viel sagen ich habe für mein Trippmeter einen eigentlich fertigen code verwendet und ich habe ihn einfach für mich umgeschrieben. Warum das so seltsam ist weis ich leider nicht :frowning: Ich weiß im moment auch noch nicht ob das so geht weil ich es drausen noch nie gestestet habe und daher noch kein vernünftiges gps signal bekommen habe.

Nachdcem ich es jetzt nochmal selbst versucht habe habe ich das zucken von den potis weg bekommen ich habe einen smoothwert mit einbezogen...
z.b.
rot = 0.7 * smoothWert + 0.3 * analogRead(pot3);

Also ein teil ist schon mal gelöst.

Ja delays sind eigetnlich wirklich zu vermeiden und blockieren alles. aber da bin ich immer noch am lernen und verstehen wie ich das am besten machen kann.

Mag ein arduino es nicht wenn so eine ////////////////////////// zeile im code steht??
Das habe ich nur für mich zur "makierung" so gemacht und dann einfach gelassen :confused:

Jetzt möchte ich noch gerne die Taste die ich am keypad drücke auf dem lcd angezeigt bekommen. Aber bei dem Void draw 2 .

#define SwitchPIN 8
#include "U8glib.h"
#include <SPI.h>
#include <Keypad.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 9



U8GLIB_ST7920_128X64 u8g(5, 6, 7, U8G_PIN_NONE);




#include "U8glib.h"

#define botao 24
int estado_botao = 0;
int pot1        = A0;
int pot2        = A1;
int pot3        = A2;
int pot4        = A3;
int pot5        = A4;
int pot6        = A5;

int del1        = 0;
int del2        = 0;
int bright      = 0;
int rot         = 0;
int gruen       = 0;
int blau        = 0;

int smoothWert  = 0;

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns

char keys[ROWS][COLS] = { // Define the Keymap
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {37, 39, 43, 45};
byte colPins[COLS] = {47, 49, 51, 53};
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );// Create the Keypad
Adafruit_NeoPixel strip = Adafruit_NeoPixel(256, PIN, NEO_GRB + NEO_KHZ800);

void draw1() {

  u8g.setFont(u8g_font_fixed_v0);
  u8g.setPrintPos(20, 10);
  u8g.print("Matrix info:");

  smartdelay(10);
}

void draw2()
{



  u8g.setFont(u8g_font_fixed_v0);
  u8g.setPrintPos(20, 10);
  u8g.print("Matrix info:");
  u8g.setPrintPos(5, 20);
  u8g.print("Temp:");
  u8g.setPrintPos(40, 20);


  u8g.setPrintPos(5, 30);
  u8g.print("Rot:") ;
  u8g.setPrintPos(40, 30);
  u8g.print(rot) ;
  u8g.setPrintPos(65, 30);
  u8g.print("Speed1:") ;
  u8g.setPrintPos(105, 30);
  u8g.print(del1) ;
  u8g.setPrintPos(5, 40);
  u8g.print("Blau:") ;
  u8g.setPrintPos(40, 40);
  u8g.print(blau) ;
  u8g.setPrintPos(65, 40);
  u8g.print("Speed2:") ;
  u8g.setPrintPos(105, 40);
  u8g.print(del2) ;
  u8g.setPrintPos(5, 50);
  u8g.print("Grun:") ;
  u8g.setPrintPos(40, 50);
  u8g.print(gruen) ;
  u8g.setPrintPos(5, 60);
  u8g.print("Hell:") ;
  u8g.setPrintPos(40, 60);
  u8g.print(bright) ;


  if (keyin != NO_KEY)
    u8g.setPrintPos(65, 105);
  u8g.print(keyIn);
  else
  { u8g.setPrintPos(65, 105);
    u8g.print(" -- " ) ;
  }


  smartdelay(10);

}

void draw3()
{
  u8g.setFont(u8g_font_fixed_v0);

  u8g.setPrintPos(5, 20);
  u8g.print("Temp:");

  smartdelay(10);
}


void setup(void) {

  sensors.begin();


  if ( u8g.getMode() == U8G_MODE_R3G3B2 )
    u8g.setColorIndex(255);     // white
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
    u8g.setColorIndex(3);         // max intensity
  else if ( u8g.getMode() == U8G_MODE_BW )
    u8g.setColorIndex(1);         // pixel on

  pinMode(SwitchPIN, INPUT_PULLUP); // Setzt den Digitalpin 13 als Outputpin
  pinMode(botao, INPUT_PULLUP);
  strip.begin();
  strip.show();

  smartdelay(1);
  pinMode(12, OUTPUT);


}

void loop(void) {
  digitalWrite(12, HIGH);
  bright    = analogRead(pot5); // wir legen fest, dass die Variable pot1_wert für uns den Wert des Potis speichert
  bright    = 0.7 * smoothWert + 0.3 * analogRead(pot5); // wir legen fest, dass die Variable pot1_wert für uns den Wert des Potis speichert
  bright    = map(bright, 0, 1023, 0, 240);
  del1      = 0.7 * smoothWert + 0.3 * analogRead(pot1);
  del2      = 0.8 * smoothWert + 0.2 * analogRead(pot6);
  rot       = 0.7 * smoothWert + 0.3 * analogRead(pot4);
  rot       = map(rot, 0, 1023, 0, 255);
  gruen     = 0.8 * smoothWert + 0.2 * analogRead(pot2);
  gruen     = map(gruen, 0, 1023, 0, 255);
  blau      = 0.7 * smoothWert + 0.3 * analogRead(pot3);
  blau      = map(blau, 0, 1023, 0, 255);
  sensors.requestTemperatures();
  float tempC = sensors.getTempCByIndex(0);
  static char key;
  char keyIn = kpd.getKey();
  boolean valor_botao = digitalRead(24);



  if (valor_botao != 1)
  {
    while (digitalRead(24) != 1)
    {
      delay(10);
    }
    // Inverte o estado
    estado_botao++;
    estado_botao %= 3;
  }

  //picture loop
  u8g.firstPage();
  do {
    if (estado_botao == 0)
    {
      draw1();
    }
    if (estado_botao == 1)
    {
      draw2();
    }
    if (estado_botao == 2)
    {
      draw3();
    }
  }
  while ( u8g.nextPage() );
  delay(10);
  

  if (keyIn) key = keyIn;

  if (key) // Check for a valid key.
  {
    switch (key)
    {

      case '1':

        {
          strip.fill(strip.Color(0, 0, 255), 8, 8);
          strip.fill(strip.Color(0, 0, 255), 16, 8);
          strip.fill(strip.Color(0, 0, 255), 40, 8);
          strip.fill(strip.Color(0, 0, 255), 48, 8);
     
          strip.setBrightness(bright);
          strip.show();
          
          
          smartdelay(del2);
        }
        break;


      case '2':


        {
          
          strip.setPixelColor(193, (strip.Color(255, 90, 0)));
          strip.setBrightness(bright);
          strip.show();
          smartdelay(del1);
          
          
        }
        break;

      case '3':


        
        strip.setPixelColor(159, (strip.Color(139, 0, 139)));
        strip.setBrightness(bright);
        
        strip.show();
       
        smartdelay(600);

        break;




      case 'A':

       
        strip.setPixelColor(157, (strip.Color(139, 0, 139)));
        strip.setBrightness(bright);
        strip.show();

        smartdelay(del1);
       
        

        break;


      case '4':

        strip.fill(strip.Color(255, 255, 255), 0, 256);
        strip.setBrightness(bright);
        strip.show();

        break;


      case '5':

        strip.fill(strip.Color(rot, gruen, blau), 0, 256);
        strip.setBrightness(bright);
        strip.show();

        break;

      case '6':
        strip.fill(strip.Color(rot, gruen, blau), 0, 256);
        strip.setBrightness(bright);
        strip.show();
        smartdelay(del2);
        strip.clear();
        strip.show();
        smartdelay(del2);
        break;

      //case 'B':
      //break;
      //case '7':
      //case '8':
      //case '9':
      //case 'C':
      //case '*':
      //case '0':
      //case '#':

      case 'D':

        strip.clear();
        strip.show();
        break;


      default:
        Serial.println(key);

    }
  }

  
}





static void smartdelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    if (!(digitalRead(SwitchPIN)))   // read the input pin
    {
      delay(100);   //debouncing
      if (!Button1Pressed)
      {
        Button1Pressed = true;
        TargetGpsLAT = gps.location.lat();
        TargetGpsLON = gps.location.lng();
        u8g.setFont(u8g_font_fixed_v0);
        u8g.setPrintPos(5, 60);
        u8g.print("W:");
        u8g.setPrintPos(10, 60);
        u8g.print(TargetGpsLAT, 4); // Raw longitude in whole degrees
        u8g.setPrintPos(80, 60);
        u8g.print(" L:");
        u8g.setPrintPos(90, 60);
        u8g.print(TargetGpsLON, 4); // Raw longitude in whole degrees
      }
    }  else
    {
      Button1Pressed = false;
    }

    while (Serial1.available())
      gps.encode(Serial1.read());
  } while (millis() - start < ms);
}

Das ist im loop eine lokale Variable, die außerhalb von loop nicht bekannt ist.
Mache sie global und nutze im loop nur keyIn = kpd.getKey();

Dann kannst Du sie auch in den anderen Funktuinen benutzen.

Gruß Tommy

Meine ehrliche Antwort wird Dir nicht gefallen.
Du hast Dir etwas zusammenkopiert und das weder inhaltlich noch funktional verstanden.

Und das wird so nichts.
Nachtrag: Tommy war schon wieder schneller - ich hätte mich auf key festgelegt und keyin weg gehauen.)

if (keyIn) key = keyIn;
  if (key) // Check for a valid key.
  {
    switch (key)

Ok - dann zieh ich hier mal zurück :wink:

Sollst Du nicht. Ich habe nur einen Hinweis gegeben.
Du weist doch: Frage 2 Programmierer und Du bekommst 4 Aussagen :wink:

Gruß Tommy

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.