Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #include<EEPROM.h>
  2.  
  3. float Tvoltage, Lvoltage;
  4. float temp, lite;
  5. int tempPin = A0;
  6. int litePin = A5;
  7. int tempReading, liteReading;
  8. int address1 = 0;
  9. int address2 = 500;
  10.  
  11. void setup() {
  12.  
  13. Serial.begin(9600);
  14. pinMode(3,INPUT);
  15. digitalWrite(3,HIGH);
  16. pinMode(A0,INPUT);
  17. pinMode(A5,INPUT);
  18. pinMode(12,OUTPUT);
  19. pinMode(13,OUTPUT);
  20.  
  21. }
  22.  
  23. void loop() {
  24.  
  25. tempReading = analogRead(tempPin);
  26. delay(100);
  27. liteReading = analogRead(litePin);
  28. delay(100);
  29. /*tempPrint();
  30. litePrint();*/
  31. if(digitalRead(3) == HIGH) {
  32.  
  33. byte tempData = map(tempReading,0,1023,0,255);
  34. byte liteData = map(liteReading,0,1023,0,255);
  35. if(address1 < 500){
  36.  
  37. EEPROM.write(address1,tempData);
  38. digitalWrite(12,HIGH);
  39. delay(500);
  40. digitalWrite(12,LOW);
  41. EEPROM.write(address2,liteData);
  42. digitalWrite(13,HIGH);
  43. delay(500);
  44. digitalWrite(13,LOW);
  45. Serial.print("recorded to: ");
  46. Serial.println(address1);
  47. address1++;
  48. address2++;
  49. delay(5000);
  50.  
  51. } else {
  52.  
  53. digitalWrite(12,HIGH);
  54. digitalWrite(13,HIGH);
  55. while(1);
  56.  
  57. }
  58.  
  59. }
  60.  
  61. }
  62.  
  63. void tempPrint(){
  64.  
  65. Tvoltage = tempReading * .0049;
  66. Serial.println("Voltage from LM34: ");
  67. Serial.print(Tvoltage);
  68. temp = (Tvoltage * 100.0);
  69. Serial.println("Temperature: ");
  70. Serial.print(temp);
  71. Serial.print((char)179);
  72. Serial.print("F");
  73.  
  74. }
  75.  
  76. void litePrint(){
  77.  
  78. Lvoltage = liteReading * .0049;
  79. Serial.print("Voltage from photocell: ");
  80. Serial.print(Lvoltage);
  81. lite = map(liteReading,0,1023,0,100);
  82. Serial.print("light: ");
  83. Serial.print(lite);
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement