Created
October 29, 2017 17:58
-
-
Save stevelord/d2d39579bdc30497ded8032633aa416d to your computer and use it in GitHub Desktop.
A (better) EMF detector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SAMPLES 250 | |
unsigned int state = 0; | |
unsigned long total = 0; | |
void setup() { | |
} | |
void loop() { | |
for (int i = 0; i < SAMPLES; i++){ | |
total += analogRead(A1); | |
} | |
state = total / SAMPLES; | |
state = constrain(state, 0, 100); | |
state = map(state, 0, 100, 0, 255); | |
analogWrite(PB1,state); | |
total = 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment