3026 views|0 replies

1w

Posts

25

Resources
The OP
 

EMF detector using ATtiny24A-PU [Copy link]

From: https://www.hackster.io/TruePatrick/emf ... -pu-32244f

picture


picture

picture


Schematic

picture


Code

// EMF Detector Attiny85 and 4 led v1.0// 23.10.2015// original code/project by Aaron ALAI - aaronalai1@gmail.com// modified for use by Patryk Bedkowski - bedkowskisite@gmail.com

#define NUMREADINGS 15 // Number of readings
int senseLimit = 16; // Raise this num to decrease sensitivity
int val = 0; 
int antenna = A7;
int LED[] = {0,1,2,3,4,5,6}; // After verify the position of red green and yellow leds
// Variables for smoothing
int readings[NUMREADINGS];
int index = 0;
int total = 0;
int averange = 0;
void setup() {
  for(int i=0;i<7;i++){
    pinMode(i, OUTPUT);
  }
pinMode(antenna, INPUT);
// Test leds on start
for (int i=0; i<7; i++) {
digitalWrite(LED[i],HIGH);
delay(250);
}
for (int i=0; i<7; i++) {
digitalWrite(LED[i],LOW);
}
// Initialize all the readings
for (int i = 0; i < NUMREADINGS; i++) {
readings[i] = 0;
}
}
void loop() {
int val = analogRead(antenna);
if(val >= 1){
val = constrain(val, 1, senseLimit); // turn any readings higher than the senseLimit into the senseLmit
val = map(val, 1, senseLimit, 1, 1023); // remap the values
total -= readings[index]; // subtract the last reading
readings[index] = val;    // read from the sensor
total+= readings[index];  // add the reading to the total
index = (index + 1);      // advance to the next index
if (index >= NUMREADINGS)index = 0;
averange = total / NUMREADINGS;

if (averange > 380) {
digitalWrite(0,HIGH);}
else{digitalWrite(0,LOW);}

if (averange > 480){
digitalWrite(1,HIGH);}
else{digitalWrite(1,LOW);}

if (averange > 580){
digitalWrite(2,HIGH);}
else{digitalWrite(2,LOW);}

if (averange > 680){
digitalWrite(3,HIGH);}
else{digitalWrite(3,LOW);}

if (averange > 780){
digitalWrite(4,HIGH);}
else{digitalWrite(4,LOW);}

if (averange > 830) {
digitalWrite(5,HIGH);}
else {digitalWrite(5,LOW);}

if (averange > 900) {
digitalWrite(6,HIGH);}
else {digitalWrite(6,LOW);}
}}

This post is from DIY/Open Source Hardware
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list