Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Emily Gertz
file 70 lines (49 sloc) 1.1 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
// Arduino Electromagnetic interference detector
// Code modified by PAtrick Di Justo, based on
// Aaron ALAI EMF Detector April 22nd 2009 VERSION 1.0
// aaronalai1@gmail.com
//
// This outputs sound and numeric data to the 4char


#include <SoftwareSerial.h>
#define SerialIn 2
#define SerialOut 7


#define wDelay 900

int inPin = 5;
int val = 0;

SoftwareSerial mySerialPort(SerialIn, SerialOut);

void setup()
{
  pinMode(SerialOut, OUTPUT);
  pinMode(SerialIn, INPUT);

  mySerialPort.begin(19200);
  mySerialPort.print("vv");

  mySerialPort.print("xxxx");
  delay(wDelay);
  mySerialPort.print("----");
  delay(wDelay);
  mySerialPort.print("8888");
  delay(wDelay);
  mySerialPort.print("xxxx");
  delay(wDelay);

  Serial.begin(9600);

}


void loop()
{

 val = analogRead(inPin);

 Serial.println(val);
 dispData(val);
 val = map(val, 1, 100, 1, 2048);
 tone(9,val,10);

}



void dispData(int i)
{
   if((i<-999) || (i>9999))
 {
   mySerialPort.print("ERRx");
   return;
 }
 char fourChars[5];
 sprintf(fourChars, "%04d", i);

 mySerialPort.print("v");
 mySerialPort.print(fourChars);
  
}
Something went wrong with that request. Please try again.