forked from VAR-solutions/Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEMF_Detector_upd.ino
More file actions
40 lines (23 loc) · 1.63 KB
/
EMF_Detector_upd.ino
File metadata and controls
40 lines (23 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*This project measures the EMF intensity around any ac electrical appliances by LED
* this project is one of the simplest one that you can try.
* Before attempting the project get some idea about constrain() and map() functions in arduino math
* the fritzing sketch regarding the project can be found in Arduino101 repository
- Abhyuday */
int antPin = 7; // antenna Pin to analog 7
int analogValue = 0; // store small analog voltage values to analogValue and initialise it to 0
int LED = 11; // Detection LED to A11
void setup() {
Serial.begin(9600); // Beginning Serial Connection at 9600 Baud
}
void loop() {
analogValue = analogRead(antPin); //Read analog values from antPin and assign them to analogValue
if(analogValue >= 1) //if antPin sense analog wave in environment
{
analogValue = constrain(val, 1, 100); //ranging the analogValue in (1 to 100)scale
analogValue = map(analogValue, 1, 100, 1, 255); //remapping analogValue in (1 to 255) scale
analogWrite(LED, analogValue); // HIGH the LED according to intensity of analogValue
}else{
analogWrite(LED, 0); //if antPin sense nothing then put LED at LOW
}
Serial.println(analogValue);
}