Hello everyone,
I'm really new to this microcontroller.
I'm using a sharp IR sensor GP2Y0A21 and I already have the code (credits to the one who made it, totally forgot) but I cant figure out how to put this code on a EEPROMwrite/read sketch.
I'm using it as stage level and i'ts giving me accurate-ish distance but it seems i dont know how to store it to EEPROM.
Can someone please help me how to put this code to an EEPROMwrite/read sketch??
int IRpin = 1; // analog pin for reading the IR sensor
void setup() {
Serial.begin(9600); // start the serial port
}
void loop() {
float volts = analogRead(IRpin)*0.0048828125; // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
float distance = 27*pow(volts, -1.10); // worked out from graph 27 = theretical distance / (1/Volts)S - luckylarry.co.uk
Serial.println(distance); // print the distance
delay(1000); // arbitary wait time.
}
Thanks.
Cheers.