des stimmt ... hmm
ok ich gebe zu mein problem ist ich bin zu doof/unerfahren
wenn ich jetzt in den cases switchen will bleibt er in case 1 bei der temperatur hängen und bekomme ihn dort nicht mehr wech .... dachte jetzt bint einer interrupt routine könne ich das problem lösen aber vllt kannst du mir einen anderen weg zeigen und mir ein paar tipps geben.
Am ende soll es eigendlich eine wetterstation ergeben die aus 2 atmegas besteht die via funk miteinander komunizieren sollen draussen werden temperatur, luftdruck, windgeschwindigkeit, windrichtung usw ermittelt und an die arduino drinnen gesendet die diese sachen erstmal auf einem 16x2lcd ausgeben soll und später auf nem glcd 128x64.
hier mal mein code bitte net lachen vermute mal das es im groben ganz großer bock mist ist aber es ist mein erstes projekt mit einem arduino ....
#include <LiquidCrystal.h>
float tempC = 0; // variable for holding Celcius temp (floating for decimal points precision)
float tempf = 0; // variable for holding Fareghneit temp
int tempPin = 0; // Declaring the Analog input to be 0 (A0) of Arduino board.
float samples[8]; // array to hold 8 samples for Average temp calculation
float maxi = 0,mini = 100; // max/min temperature variables with initial values. LM35 in simple setup only measures Temp above 0.
int i;
int ButtonDown = 8;
int backLight = 13; // pin 13 schaltet die hintergrundbeleuchtung
int page;
// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
void setup()
{
pinMode(ButtonDown, INPUT);
pinMode(backLight, OUTPUT);
digitalWrite(ButtonDown, LOW);
digitalWrite(backLight, HIGH); //LCD Licht an
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Wetterstation");
lcd.setCursor(0,1);
lcd.print("Version 1.0");
delay(2000); //Wartet 2 Sekunden
lcd.clear();
}
void loop(){
if (digitalRead(ButtonDown) == HIGH)
page = (page+1)%3; // Dreiseitiges Menue. '%' ('modulo') sorgt dafuer dass nach '2' wieder '0' kommt...
switch (page) {
case 0: // erste Seite
lcd.setCursor(0,0);
lcd.print("Case0");
lcd.setCursor(0,1);
lcd.print("Zeit Datum");
break;
case 1: //zweite Seite
for(i = 0;i<=7;i++){ // gets 8 samples of temperature
samples[i] = ( 4.4 * analogRead(tempPin) * 100.0) / 1024.0;
lcd.clear();
lcd.setCursor(0, 0); // set LCD cursor position
lcd.print("Innen: "); // print to LCD
lcd.setCursor(12, 0);
lcd.print(samples[i]); // print current Temp sample to LCD
lcd.setCursor(0,1);
lcd.print("Aussen:");
lcd.setCursor(12, 1);
lcd.print("N/A");
delay(1000);
}
break;
case 2: // dritte Seite
lcd.setCursor(0,0);
lcd.print("Case2");
lcd.setCursor(0,1);
lcd.print("Luft Wind");
break;
}
}