/* This code is to Remove ambience noise from sensor data. IR LED connected to Digital pin: 4 IR diode connected to analog input:A3 by-Abhilash Patel Adapted from the above Arduino Code On the ATTiny45 Sensor Board the IR LED is connected PB4 (ATTiny45 Pin 3) IR Diode is connected to PB3 = A3 (ATTiny45 Pin 2) */ #include SoftwareSerial mySerial(2, 1); // RX, TX int a, b, c; void setup() { mySerial.begin(4800); mySerial.println("Hello, world"); mySerial.println("start sensing"); pinMode(4, OUTPUT); } void loop() { digitalWrite(4, HIGH); //Turning ON LED delayMicroseconds(500); //wait a = analogRead(A3); //take reading from photodiode(pin A3) :noise+signal digitalWrite(4, LOW); //turn Off LED delayMicroseconds(500); //wait b = analogRead(A3); //again take reading from photodiode :noise c = a - b; //taking differnce:[ (noise+signal)-(noise)] just signal mySerial.print(a); //noise+signal mySerial.print("\t"); mySerial.print(b); //noise mySerial.print("\t"); mySerial.println(c); //denoised signal }