comparison Potentiometer.cpp @ 5:ea44b28e12ab

1.0.2 update - setup now resets the object
author ark
date 2017-06-22 01:42 +0200
parents a5e06e87f081
children 4e32bc18a7f7
comparison
equal deleted inserted replaced
4:53e0509faa3c 5:ea44b28e12ab
1 #if defined(ARDUINO) && ARDUINO >= 100
2 #include "Arduino.h" 1 #include "Arduino.h"
3 #else
4 #include "WProgram.h"
5 #endif
6
7 #include "Potentiometer.h" 2 #include "Potentiometer.h"
8 3
9 4
10 /** 5 /**
11 see Potentiometer.h for description. 6 see Potentiometer.h for description.
14 Potentiometer::Potentiometer() {} 9 Potentiometer::Potentiometer() {}
15 10
16 void Potentiometer::setup(byte pin) { 11 void Potentiometer::setup(byte pin) {
17 this->pin = pin; 12 this->pin = pin;
18 pinMode(this->pin, INPUT); 13 pinMode(this->pin, INPUT);
14 this->isStopped = false;
15 this->sum = 0.0;
16 this->avg = 0.0;
17 this->num = 0;
19 } 18 }
20 19
21 void Potentiometer::update() { 20 void Potentiometer::update() {
22 int v = analogRead(this->pin); 21 int v = analogRead(this->pin);
23 // if value is within jitter threshold of current value, add to average 22 // if value is within jitter threshold of current value, add to average