Advertisement
Guest User

Untitled

a guest
Nov 16th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. double values[15];
  2. boolean firstRun=true;
  3. double tip=0;
  4. double realVoltage=0;
  5. int j=0;
  6. void setup(){
  7. Serial.begin(9600);
  8. Serial.println("Serial Started w00t");
  9. }
  10.  
  11. void loop(){
  12. tip=analogRead(0);
  13. if(tip>50){
  14. Serial.print("Incoming Voltage is ");
  15. Serial.println(tip);
  16.  
  17. if(firstRun){
  18. for(int i=0;i<15;i++){
  19. values[i]=tip;
  20. }
  21. delay(4000);
  22. firstRun=false;
  23. }
  24. values[j]=tip;
  25. tip=0;
  26. for(int i=0;i<15;i++){
  27. tip+=values[i];
  28. }
  29. tip/=15;
  30. realVoltage = ((((tip*(5.0/1023.0))*7000)/5000)*50);
  31. Serial.print("Real voltage: ");
  32. Serial.println(realVoltage);
  33. j++;
  34. if(j>=15){
  35. j=0;
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement