Skip to content

VI. Programming

I found some example projects and interesting information about the TCRT5000 at Electrodragon and also on Instructables

I’ve tried to program the Sensor Board (old Layout) with the programmer as in the Electronics Design week, but I had no success !!! I wasn’t able to flash the bootloader, the Attiny45 is not responding to whatever I’ve tried.

However I have to make a new board, because of design mistakes caused by missing resistors and additionally really bad cold solder points.
The frankstein mod doesn’t solved the problem !

The problems are solved with the new board

My program code is based on the one from instructables
I customized it, for the Attiny45 by adding a softserial interface

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 1); //RX, TX

and changing the pins. The IR LED is connected PB4 = 4 (ATTiny45 Pin 3) and the IR Diode is connected to PB3 = A3 (ATTiny45 Pin 2).

Here is a code snippet

  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

HERE is the complete code.

The serial output is split into three columns.

  • The left one, shows noise + signal
  • In the middle, is the noise
  • The right one, shows the denoised signal

Here is a short video of the measuring process