Advertisement
Guest User

Untitled

a guest
Nov 16th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. boolean firstRun=true;
  2. double tip=0;
  3. double last=0;
  4. double realVoltage=0;
  5. void setup(){
  6. Serial.begin(9600);
  7. Serial.println("Serial Started w00t");
  8. last=analogRead(0);
  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. last=last+((tip-last)/5);
  18. Serial.print("avg voltage is ");
  19. Serial.println(last);
  20. realVoltage = ((last*6.83593)/1000); // 7k/5k*5000mV/1024
  21. Serial.print("Real voltage: ");
  22. Serial.println(realVoltage);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement