Pages: [1]   Go Down
Author Topic: Storing this code to EEPROM (SHARP IR SENSOR)  (Read 1222 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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??


Code:
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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 610
Posts: 49037
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can someone please help me how to put this code to an EEPROMwrite/read sketch??
What do you want to write to EEPROM? Why?
Logged

Pages: [1]   Go Up
Jump to: