Advertisement
Guest User

Untitled

a guest
Nov 16th, 2012
83
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>150){
  14. // Serial.print("Incoming Voltage is ");
  15. // Serial.println(analogRead(0));
  16.  
  17. if(firstRun){
  18. for(int i=0;i<15;i++){
  19. values[i]=tip;
  20. }
  21. firstRun=false;
  22. }
  23. values[j]=tip;
  24. tip=0;
  25. for(int i=0;i<15;i++){
  26. tip+=values[i];
  27. }
  28. tip/=15;
  29. realVoltage = ((((tip*(5.0/1023.0))*7000)/5000)*50);
  30. //Serial.print("Real voltage: ");
  31. Serial.println(realVoltage);
  32. j++;
  33. if(j>=15){
  34. j=0;
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement