Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<EEPROM.h>
- float Tvoltage, Lvoltage;
- float temp, lite;
- int tempPin = A0;
- int litePin = A5;
- int tempReading, liteReading;
- int address1 = 0;
- int address2 = 500;
- void setup() {
- Serial.begin(9600);
- pinMode(3,INPUT);
- digitalWrite(3,HIGH);
- pinMode(A0,INPUT);
- pinMode(A5,INPUT);
- pinMode(12,OUTPUT);
- pinMode(13,OUTPUT);
- }
- void loop() {
- tempReading = analogRead(tempPin);
- delay(100);
- liteReading = analogRead(litePin);
- delay(100);
- /*tempPrint();
- litePrint();*/
- if(digitalRead(3) == HIGH) {
- byte tempData = map(tempReading,0,1023,0,255);
- byte liteData = map(liteReading,0,1023,0,255);
- if(address1 < 500){
- EEPROM.write(address1,tempData);
- digitalWrite(12,HIGH);
- delay(500);
- digitalWrite(12,LOW);
- EEPROM.write(address2,liteData);
- digitalWrite(13,HIGH);
- delay(500);
- digitalWrite(13,LOW);
- Serial.print("recorded to: ");
- Serial.println(address1);
- address1++;
- address2++;
- delay(5000);
- } else {
- digitalWrite(12,HIGH);
- digitalWrite(13,HIGH);
- while(1);
- }
- }
- }
- void tempPrint(){
- Tvoltage = tempReading * .0049;
- Serial.println("Voltage from LM34: ");
- Serial.print(Tvoltage);
- temp = (Tvoltage * 100.0);
- Serial.println("Temperature: ");
- Serial.print(temp);
- Serial.print((char)179);
- Serial.print("F");
- }
- void litePrint(){
- Lvoltage = liteReading * .0049;
- Serial.print("Voltage from photocell: ");
- Serial.print(Lvoltage);
- lite = map(liteReading,0,1023,0,100);
- Serial.print("light: ");
- Serial.print(lite);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement