11. Input devices

This week is very exciting for my to discover a lot of sensors and learn how can we read the data from sensors and using it as input for another device to make an interactive project. So it seems an easy thing but actually the sensors is very tricky if something wrong in their values. So I hope to close this issue for me and be a good reader of sensors.

The Lecture of Input Devices includes many different sensors, all of them very exciting to test!

Why this sensor

I select one sensor for this week as a start and if I have more time I will test more. So after our discussion in the local session, we decided to use the sensor that reflect in our final project. So the phototransistor will be my first one.

This Project will help me in this assignment to track the sunlight Arduino Solar Tracker

Redesign my board

I used Eagle as usual to design my board. I used the Neil’s board as a reference for me.

I excited to make my PCB 3D It’s not my first time to try this “Haggag explain this for me before”, So I export my board to Fusion 360. This is a clear tutorial from Autodesk that explain every step to integration Eagle with Fusion 360

You can use the tools below to hide the component or explode model is very nice also to show the traces. Also the above left “In this cube” you can chose different views.

Then I export the images from Eagle with 2000 resolution and monochrome then edit it in GIMP.

Fabricate my board

I usually used one offset to make sure of all traces will mills.

Weld and Programming the microcontroller ‘ATtiny 45’

This is my second time and first time in the fab academy to try weld with soldering station. And it’s very bad experience for me. I didn’t like soldering station any more. and hope to not use it again. It’s very cold, and takes 60 hours to solder just one component, and after finishing the result is very messy and the solder not shinny that because the low of heat.

Ohadion advice us to use maximum heat 250 to not burn our board. I started in KADA 852+ with 250 and waiting about 10 minutes, but it looks closed, there is any changes with heat. So I started to increase the heat, I reached to 400 but still not working well. So Haggag advice me to work in Soldering Station 878D Amazon link with 450 heat after testing many results. So this is the result!

So this is the super result I have been reached after one and half hour to solder 7 Components!

Usually I used soldering iron for soldering, I know it’s not the default and it’s very tricky because the heat could burn your microcontroller. But it’s very wonderful for me, I used it for mmmm about 5 times and it’s very comfortable, easy and faster. You have to be very sensitive and carful when using it and you will achieve the best result.

Unfortunately I don’t have a picture after solder the phototransistor. But when I reach to this point, the question is where is the Emitter and the Collector?!

I google it and didn’t find the answer. So I decided to rack my brain and answered me for this question!

So I opened the Neil’s board with Components and the board

From the board photo I know the Emitter and Collector direction, then I zoomed in the phototransistor Component. Hopefully I didn’t notice the green mark! but I noticed the drawing on the top of phototransistor ‘I don’t know what it means’ but I take this drawing as a new mark for me!

Sure there is no logic for my analysis! But anyway I continued!


For programming

We need to program our microcontroller ‘ATtiny 45’ So we used our USB board, that we made in electronics production week and using make file that Neil shared in the lecture.

make -f hello.bus.45.make program-usbtiny

  • -f to select the file that we need to maker
  • hello.bus.45.make … we have to write the exactly name file without any changes
  • program-usbtiny … the exactly function we need to do

  • Then, we need to write this line

avrdude -p t45 -P usb -c usbtiny -U flash:w:hello.bus.45.c.hex

  • -p to specify the type of avrdude ‘t45’, attiny45
  • -p to specify the connection port … usb
  • -c to select the programmer ‘usbtiny’
  • -U to specify the memory operation

  • For this step we need to program the sensor PCB, Actually I used the Neil’s Code without any changes. I’m still learning C so I hope in next assignments could learn more and more.


Test the values

When I said to Haggag that I made in phototransistor, He wants to make sure first that the board is working. So we test it in his Mac ‘he loves his PC so much, God bless it :)’. So we downloaded Neil’s Code and test it. So the results isn’t the same.


The Emitter and Collector of Phototransistor

Yes, It’s totally true, Our only reference is datasheet. We should to review all datasheets for any component before start design.

So after back to the datasheet of phototransistor PT15-21C/TR8, We will find that the Collector have a green mark.

So I desolder it and soldered a new component with the right direction.


Python Code

Now we reach to the point of this assignment!

WE need to read the data of the sensor. I didn’t learn the python and I don’t have an idea how it works. The first time I used it when I installed it to make this website, and I just followed the Tutorial. So it’s the same here Neil shared two codes for this sensor C code and python code. I chosen the python because I installed it before. But Haggag help me in this step. The code of Neil with python 2 and I have python 3. So we need some edits in code to match the two versions.

The edit we make

  • in line 15, we write
  from tkinter import *

instead of

  from Tkinter import *
  • line 56, We write
  print("command line: hello.light.45.py serial_port")

instead of

  print "command line: hello.light.45.py serial_port"

This is all different between python 2 and 3

Photoresistor Sensor from Nada Gamal on Vimeo.


Download Files

The phototransistor PCB


If you faced an issue with Eagle files, please download it as zip file

Phototransistor Board_zip



The code