Anzeige |
In Antwort auf
da es mit dem Anhang anscheinend nicht geklappt hat, ist hier nocheinmal der Programmtext.:
#include <LiquidCrystal.h> //Bibliothek
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Pins
int KnopfPin = A1;
int buttonState = 0;
int x=0;
int KnopfPin2 = A2;
int buttonState2 = 0;
int o = 0;
String St,M,S;
int SEK = 0;
int MIN = 0;
int STU = 0;
int a = 0;
void setup (){
lcd.begin(16, 1);
pinMode (A0, INPUT);
pinMode (A1, INPUT_PULLUP);
pinMode (A2, INPUT_PULLUP);
a = analogRead (A0);
}
void loop()
{
lcd.setCursor(0, 2);
int a = analogRead (A0); //Zahlvariable auf A0 festlegen
delay (1000); //Verzögerung zum einfacheren Ablesen
double t = 0.244680851*a-119.89; //Variable für Temperatur (Rechnung extern)
lcd.print (t); // Temperatur auf Arduino anzeigen
lcd.print ("C");
lcd.setCursor(0, 0);
buttonState = digitalRead (KnopfPin);
if (buttonState == LOW)
{
x= x+1;
if (x==59)
{
x=0;
}
buttonState2 = digitalRead (KnopfPin2); // funzt noch ned
if (buttonState2 == LOW)
{
o= o+1;
if (o==23)
{
o=0;
}
}
}
S = String (SEK);
M = String (MIN);
St = String (STU);
if (SEK==60) //wenn Sekunde = 60 dann setze S 0 und erhöhe M um 1
{SEK=0;
MIN=MIN+1;}
if (MIN==60)
{MIN=0;
STU=STU+1;}
if (STU==24)
{STU=0;
MIN=0;
SEK=0;}
St=String(millis()/3600000+o*3600000); //funzt noch ned
if (St.length ()<2){St="0"+St;}
M=String(millis()/60000+x);
if (M.length()<2){M="0"+M;}
S=String((millis()/1000%60));
if (S.length()<2){S="0"+S;}
lcd.print(St+":"+M+":"+S+"");
}
|
![]()
Das Forum hat 135
Themen
und
218
Beiträge.
|
![]() | Forum Software von Xobor.de Einfach ein Forum erstellen |