Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 28 additions & 31 deletions code/simple/simple.ino
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
int switch1;
float switch1Smoothed;
float switch1Prev;

void setup() {

Serial.begin(115200);

pinMode(12, INPUT_PULLUP);

}

void loop() {

switch1 = digitalRead(12); // read switch
switch1 = switch1 * 100; // multiply by 100

// *** smoothing ***

switch1Smoothed = (switch1 * 0.05) + (switch1Prev * 0.95);

switch1Prev = switch1Smoothed;

// *** end of smoothing ***

Serial.print(switch1); // print to serial terminal/plotter
Serial.print(" , ");
Serial.println(switch1Smoothed);

delay(10); // run loop 100 times/second

int switch1;
float switch1Smoothed = 0;

void setup() {

Serial.begin(115200);

pinMode(12, INPUT_PULLUP);

}

void loop() {

switch1 = digitalRead(12); // read switch
switch1 = switch1 * 100; // multiply by 100

// *** smoothing ***

switch1Smoothed = (switch1 * 0.05) + (switch1Smoothed * 0.95);

// *** end of smoothing ***

Serial.print(switch1); // print to serial terminal/plotter
Serial.print(" , ");
Serial.println(switch1Smoothed);

delay(10); // run loop 100 times/second

}