Pages: [1]   Go Down
Author Topic: Saving light data to EEPROM?  (Read 1506 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Basically I wrote a program that senses the light value and writes it to an LCD and then after 30 minutes it skips a space in the LCD and writes the next light value. I ran this at night to see the light change over time basically but my battery kinda died on me so the info was not salvaged.

I want to save this info to the EEPROM and then later look at it through my computer. The data is just a simple value from 0-1023 (i think it's to 1023) . I don't even need to save the time either but it would be nice if I could too.

Anyone know how to do this?

so far the code I'm using is this:

Code:
#include <LiquidCrystal.h>
#include <EEPROM.h>

/*
LCD Connections:
 rs (LCD pin 4) to Arduino pin 12
 rw (LCD pin 5) to Arduino pin 11
 enable (LCD pin 6) to Arduino pin 10
 LCD pin 15 to Arduino pin 13
 LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
 
 Cds Connections:
 CdS Pin 1 to +5v
 CdS Pin 2 to Analog Pin 0
 10k ohm resistor pin 1 to Analog Pin 0
 10k ohm resistor pin 2 to Gnd
 */

LiquidCrystal lcd(7,8,9,10,11,12);

int sensorPin = 5;
int val = 0;


void setup() {

  Serial.begin(9600);
  // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  lcd.begin(16, 4);              // rows, columns.  use 16,2 for a 16x2 LCD, etc.
  lcd.clear();                   // start with a blank screen
  lcd.setCursor(0,0);            // set cursor to column 0, row 0
  lcd.print("Light level is:");
}



void loop() { 

   
   lcd.setCursor(3,1);
   lcd.print("   ");
  val = analogRead(sensorPin);
  val= map(val,0,1023,1,255);
  Serial.println(val);
  lcd.setCursor(2,1);
  lcd.print (val);
  EEPROM.write(0,val);
 
  delay(500000);






}
« Last Edit: March 02, 2011, 11:51:26 pm by polishdude20 » Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 593
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you are not incrementing your eeprom write address
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Pages: [1]   Go Up
Jump to: