Week 13

Input Devices

Final Project


  • Measure something: add a sensor to a microcontroller board that you have designed and read it

In my Final project I Intend to use a Light Sensor.

Hence, I Decided to make a Analog Light Sensor.


I Started Referring To Niel's board as below and decided to use ATtiny45 For the same.

Reference: http://academy.cba.mit.edu/classes/input_devices/index.html

ATtiny 45

Data-sheet LINK

‚ÄčThe datasheet for Attiny 45 helped me understand that Attiny 45 has a simpler layout and a smaller footprint as compared to Attiny 44. This helped me to have a board with lesser components tha can work with lower power also as compared to that of Attiny 44.

  • Above is the PinMap of Attiny45.
  • Its very interesting to know that pin names are different then what we use in Arduino code for reference.
  • I understood that ATtiny45 is more then powerful for my application. I also understand its limitations with number of pins.
  • But for us it more then sufficient as we only need one analog input pin.


For Designing I used Eagle CAD Software


Bellow Are the Screen-shots Explaining the Designing Process.

Note: I connected the Output That is Emitter of the Photo-transistor to Pin PB3  (ADC3)


Also Connected the Respective AVRISP pin with the Pin header as mentioned aboved.

Next I went in the Board view and Started Arranging the Components.

Download the eagle fab DRC file hear


Net Classes Settings:

Width 0.15mm

Drill 0mm

Clearance 0.5mm

Above are auto rout options. I selected the one below.

Next, I arranged the components and auto-routed it. Further I checked it by the design rules  and it showed no errors. The 'No errors' message can be seen in the bottom tab of the image above.

Resize the PCB for cutting.


  1. Attiny 44
  2. 1uF capacitor
  3. 10k Resistor
  4. 0ohm resistor 1
  5. Photo-transistor
  6. AVR ISP 6 pin header
  7. 4 pin male header


For programming the board, I prepared my Arduino  UNO to work as ISP.

Next, I connected my board with arduino using the MISO,MOSI, SCK, RST, GND and VCC pins.

Above are the pins on arduino which will be connected to Respective pin on The Input Device

Next I used the Below Code and uploaded the same.

it is a port from analog read Code.


Pin 3 is our sensor's input pin

#include <SoftwareSerial.h>

// ***

// *** Define the RX and TX pins. Choose any two

// *** pins that are unused. Try to avoid D0 (pin 5)

// *** and D2 (pin 7) if you plan to use I2C.

// ***

#define RX   1    // *** D3, Pin 2

#define TX   2  // *** D4, Pin 3


// These constants won't change.  They're used to give names


// ***

// *** Define the software based serial port. Using the

// *** name Serial so that code can be used on other

// *** platforms that support hardware based serial. On

// *** chips that support the hardware serial, just

// *** comment this line.

// ***

SoftwareSerial Serial(RX, TX);


// to the pins used:

const int analogInPin = 3;  // Analog input pin that the potentiometer is attached to

//const int analogOutPin = 9; // Analog output pin that the LED is attached to


int sensorValue = 0;        // value read from the pot

       // value output to the PWM (analog out)


void setup() {

  // initialize serial communications at 9600 bps:


   pinMode(3, INPUT);



void loop() {


  sensorValue = analogRead(3);



  // print the results to the serial monitor:

 int s = sensorValue*2;




  // wait 2 milliseconds before the next loop

  // for the analog-to-digital converter to settle

  // after the last reading:




The same code is been attached below


While Programming Select Following Settings in Arduino IDE

Board: Attiny25/45/85

processor attiny45

clock: internal 1MHz

port: arduino port

Programmer: "Arduino as ISP"

Note: If we forget to select Arduino as ISP we might program the arduino itself by mistake.

The below video shows the working of my board based on the codes I uploaded:


We can see the Serial Plotter is been used to show the sudden change in value when I stop light above photo transistor.


Attached is the Board File for The PCB


Attached is the Schematic File for The PCB from eagle software


The Arduino code is been attached.



  • Got more confident working with attiny45.
  • Got more control over eagle PCB designing skills.
  • Learned how to collect data form photo transistor