Final Project
ASSIGNMENT
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
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.
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.
Components:
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:
Serial.begin(9600);
pinMode(3, INPUT);
}
void loop() {
sensorValue = analogRead(3);
// print the results to the serial monitor:
int s = sensorValue*2;
Serial.println(s);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(1000);
}
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.