File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- int switch1;
2- float switch1Smoothed;
3- float switch1Prev;
4-
5- void setup () {
6-
7- Serial.begin (115200 );
8-
9- pinMode (12 , INPUT_PULLUP);
10-
11- }
12-
13- void loop () {
14-
15- switch1 = digitalRead (12 ); // read switch
16- switch1 = switch1 * 100 ; // multiply by 100
17-
18- // *** smoothing ***
19-
20- switch1Smoothed = (switch1 * 0.05 ) + (switch1Prev * 0.95 );
21-
22- switch1Prev = switch1Smoothed;
23-
24- // *** end of smoothing ***
25-
26- Serial.print (switch1); // print to serial terminal/plotter
27- Serial.print (" , " );
28- Serial.println (switch1Smoothed);
29-
30- delay (10 ); // run loop 100 times/second
31-
1+ int switch1;
2+ float switch1Smoothed = 0 ;
3+
4+ void setup () {
5+
6+ Serial.begin (115200 );
7+
8+ pinMode (12 , INPUT_PULLUP);
9+
10+ }
11+
12+ void loop () {
13+
14+ switch1 = digitalRead (12 ); // read switch
15+ switch1 = switch1 * 100 ; // multiply by 100
16+
17+ // *** smoothing ***
18+
19+ switch1Smoothed = (switch1 * 0.05 ) + (switch1Smoothed * 0.95 );
20+
21+ // *** end of smoothing ***
22+
23+ Serial.print (switch1); // print to serial terminal/plotter
24+ Serial.print (" , " );
25+ Serial.println (switch1Smoothed);
26+
27+ delay (10 ); // run loop 100 times/second
28+
3229}
You can’t perform that action at this time.
0 commit comments