Advertisement
RuiViana

Media

Jun 17th, 2016
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. //-----------------------------------
  2. void setup()
  3. {
  4. Serial.begin(9600);
  5. }
  6. //-----------------------------------
  7. void loop()
  8. {
  9. const int LEITURAS = 200;
  10. long soma = 0;
  11. long media = 0;
  12. //int leitura = analogRead(A5);
  13.  
  14. for (int i = 0; i < LEITURAS; i++)
  15. {
  16. int leitura = analogRead(A5);
  17. delay(2);
  18. soma += leitura;
  19. }
  20. media = soma / LEITURAS;
  21. Serial.println(media);
  22. delay(100);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement