Input devices

Assignments:
  - measure something: add a sensor to a microcontroller board that you have designed and read it.
          

Step response

Since it was quite difficult to understand the material for this week, I began with making given step response boards, and then modified temperature/sonar sensor since it was relatively easy to understand.
- Making the board is now quite easy, and all the files are from here(step response). These are what I made:

- How to use all the given c/py files:
1. Go to the folder where I put everything about hello.load.45/hello.txrx.45 files
2. Change makefile's name to 'Makefile' (no need file extension)

3. Type 'make' and enter. It will generate .hex file.
4. avrdude -c usbtiny -p attiny45 -U flash:w:filename.hex:i

5. Change usbtiny to ftdi (5V) to receive data.
6. python: install python-3.6.1.exe -> move pyserial-3.3.tar.gz into python 3.6.1 folder -> unzip, go to the folder (in the command prompt), and type 'python setup.py install' (in IDLE(shell?), click 'import serial' to check if it was installed properly.
7. Move files to python directory.
8. 'python filename.py' didn't work (in the command prompt). By checking the code for sys.argv part, I realized that the code shows that I need an extra argument for the port. 'python filename.py COM3' worked.
hello.load.45.py:

hello.txrx.45.py:

Note that I need to change 'Tkinter-->tkinter' and 'print ""-->print("")' for this version of python (3.6.1).


Temperature sensor

hello.temp.45 board:

I added one red LED so that it can blink when the temperature gets high (warm) and one blue LED so that it can blink when the temperature gets low (cool):

Blue led is connected to PB0 and red, to PB1. Both are connected to Vcc on the other side, so to turn on, need low voltage.

(Download files: trace and outline)


It kept failing to upload code through terminal.

It also kept showing error in bootloading in arduino IDE.

I couldn't figure out why. I tried to: (1) modify boards.txt file, (2) disconnect blue LED since it wasn't turned on when I connected it to USBtiny, (3) use arduino UNO instead of my USBisp, (4) use different wires to connect hello.temp.45 and USBtiny, and (5) replace attiny45 into a new one. Nothing worked. (I also checked soldering, and it seemed okay. I googled, and it seems like different issue.)

Then I noticed that I didn't connect Vcc properly. After connecting it, I could upload hello.temp.45.c and also run python file.
(By the way, don't worry about download files. I already modified those files.)



It was hard to program it so that blue light turns on when it's cold, and red light when it's hot since c code deals with the resistance change due to NTC, not the temperature. (It's python that calculate and transfer it into temperature.) Just to practice c programing (I'm a complete beginner), I just added lines so that the red/blue lights are always on.

Download c code here.


Light sensor (phototransistor)

I used phototransistor for the final project. For that, I made simpler version (two phototransistors and one servo) to test.



More details can be seen in the final development page.
Download files: Trace, Outline, and arduino code




Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.