split of from - http://forum.arduino.cc/index.php?topic=278461.msg1977322#msg1977322 -
Yea thanks polymorph, i ended up realising that
My next question is about EEPROM, i essentially have a value which can be calibrated and i want it to be stored even when i power down.
My understanding is that i need to write it as a 8 bit value between 0 and 255. So i need to somehow make a conversion from a decimal value.
and then read the value.
Im trying to read about it, but im not really sure i understand how to use it and where i need to use it.
I would probably want it to be saved after i exit my calibration menu.
heres my calibration menu code
void caseCAL()
{
lcd.clear();
lcd.print("Calibration");
delay(3000);
while(calFlag!=0)
{
lcd.clear();
lcd.print("-");
lcd.setCursor(6,0);
lcd.print(factor);
lcd.setCursor(15,0);
lcd.print("+");
lcd.setCursor(3,1);
float photoDiode_1 = analogRead(A1);
float photoDiode_2 = analogRead(A1);
float photoDiode_3 = analogRead(A1);
float averagetoprint = ((photoDiode_1)+(photoDiode_2)+(photoDiode_3))/3;
float voltage_1 = photoDiode_1 * ((5.0 / 1023.0)*1000);
float voltage_2 = photoDiode_2 * ((5.0 / 1023.0)*1000);
float voltage_3 = photoDiode_3 * ((5.0 / 1023.0)*1000);
float averageVoltage = ((voltage_1)+(voltage_2)+(voltage_3))/3;
float lux = factor * averageVoltage;
lcd.print(lux);
lcd.print(" Lux");
delay(1000);
lcd_key=read_LCD_buttons();
if(adc_key_in<50 && adc_key_in >=0) factor++;
if(adc_key_in<650 && adc_key_in >450) factor--;
if(adc_key_in<850 && adc_key_in>650)casebtnSELECT();
if(adc_key_in<850 && adc_key_in>650) calFlag=0;
}
calFlag=1;
//EEPROM.write(0,factor);
}
everything else ive basically posted before, but now i more flow control.