Ok,
Thanks again for the '' const long '' declaration and the inline one.
I be leave I did program both way like it should. But got result witch seam not right. You can see the pictures.
MINUTE_MIN Work fine giving me 10000;
Both HOURS_MIN give me 6392 and should give me 1841400 ( -xxxxx ).
INLINE DECLARATION
//const long MINUTE_MIN = 10000;
//const long MINUTE_MAX = 122400;
//const long HOURS_MIN = 1841400;
//const long HOURS_MAX = 22096800;
int potMin = 0; // potentiometer minute time
int potHours = 1; // potentiometer hours time
int ledMin = 12; // select the pin for the minute LED
int ledHours = 11; // select the pin for the hours LED
int Minute = 0; // variable to store the value coming from the sensor
int Hours = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledMin, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(ledHours, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600);
}
void loop() {
Minute = analogRead(potMin); // read the value from the Minute sensor
Hours = analogRead(potHours); // read the value from the Hours sensor
Serial.print("Min sensor = "); // print the value from the Minute sensor
Serial.print(Minute);
Serial.print("\t Time in min = "); // print the convertion in minuts
Minute = map(Minute, 0, 1023, 10000L, 122400L);
//Minute = map( Minute, 0, 1023, MINUTE_MIN, MINUTE_MAX); // 2 minut max so 0 will be 10 secound and 1020 will be 2 min .
Serial.println(Minute);
Serial.print("Hours sensor = "); // print the value from the Hours sensor
Serial.print(Hours);
Serial.print("\tTime in hours = "); // print the convertion in hours
//Hours = map( Hours, 0, 1023, HOURS_MIN, HOURS_MAX);
Hours = map( Hours, 0, 1023, 1841400L, 22096800L);
Serial.println(Hours); // 1841400 is equal to 30 minutes and 22096800 is equal to 6 hours.
Serial.println(" ");
digitalWrite(ledMin, LOW); // turn the led min ON
digitalWrite(ledHours, HIGH); // turn the led hours OFF
delay(4000);
digitalWrite(ledMin, HIGH); // turn the led min OFF
digitalWrite(ledHours, LOW); // turn the led hours ON
delay(4000);
}
DECLAIRE IN THE SCOPE
const long MINUTE_MIN = 10000;
const long MINUTE_MAX = 122400;
const long HOURS_MIN = 1841400;
const long HOURS_MAX = 22096800;
int potMin = 0; // potentiometer minute time
int potHours = 1; // potentiometer hours time
int ledMin = 12; // select the pin for the minute LED
int ledHours = 11; // select the pin for the hours LED
int Minute = 0; // variable to store the value coming from the sensor
int Hours = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledMin, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(ledHours, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600);
}
void loop() {
Minute = analogRead(potMin); // read the value from the Minute sensor
Hours = analogRead(potHours); // read the value from the Hours sensor
Serial.print("Min sensor = "); // print the value from the Minute sensor
Serial.print(Minute);
Serial.print("\t Time in min = "); // print the convertion in minuts
//Minute = map(Minute, 0, 1023, 10000L, 122400L);
Minute = map( Minute, 0, 1023, MINUTE_MIN, MINUTE_MAX); // 2 minut max so 0 will be 10 secound and 1020 will be 2 min .
Serial.println(Minute);
Serial.print("Hours sensor = "); // print the value from the Hours sensor
Serial.print(Hours);
Serial.print("\tTime in hours = "); // print the convertion in hours
Hours = map( Hours, 0, 1023, HOURS_MIN, HOURS_MAX);
//Hours = map( Hours, 0, 1023, 1841400L, 22096800L);
Serial.println(Hours); // 1841400 is equal to 30 minutes and 22096800 is equal to 6 hours.
Serial.println(" ");
digitalWrite(ledMin, LOW); // turn the led min ON
digitalWrite(ledHours, HIGH); // turn the led hours OFF
delay(4000);
digitalWrite(ledMin, HIGH); // turn the led min OFF
digitalWrite(ledHours, LOW); // turn the led hours ON
delay(4000);
}