Week 10: Input devices
Goal: measure the light with a phototransistor in a Hello.Light board
For the assignment of this week I'll make a Hello.Light board to measure the intensity of light. The first thing I do is download the documentation I need from web of the class of this week. Here I find the components of the board, the traces, the c code, the makefile and python file for visualizing the data.
To work in Python first I have to install it on your computer, and install the pyserial for python to communicate with the board through the FTDI wire connected to the USB.
For display the data in graphics, Python is going to use Tkinter, so I also have to install it.
step 1: making the board
From the image of traces I get the paths to drill de board and I weld the components as we made in the previous assignment.
Step 2: programming the board
In the windows console (for windows users like me), go to the folder where you downloaded the makefile and the c code and run them.
Important: add the port where the FabISP is installed, if we don't do it, we will get an error and we will be asked to specify the serial port.
make -f hello.light.45.make program-usbtiny COM5 |
If it works, the console will show the following text:
avr-gcc -mmcu=attiny45 -Wall -Os -DF_CPU=8000000 -I./
-o hello.light.45.out hello.light.45.c
avr-objcopy -j .text -O ihex hello.light.45.out hello.light.45.c.hex;\
avr-size --mcu=attiny45 --format=avr hello.light.45.out
AVR Memory Usage
----------------
Device: attiny45
Program: 426 bytes (10.4% Full)
(.text + .data + .bootloader)
Data: 0 bytes (0.0% Full)
(.data + .bss + .noinit)
avrdude -p t45 -P usb -c usbtiny -U flash:w:hello.light.45.c.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9206
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip avrdude: reading input file "hello.light.45.c.hex"
avrdude: input file hello.light.45.c.hex auto detected as Intel Hex
avrdude: writing flash (426 bytes):
Writing | ################################################## | 100% 1.27s
avrdude: 426 bytes of flash written
avrdude: verifying flash memory against hello.light.45.c.hex:
avrdude: load data flash data from input file hello.light.45.c.hex:
avrdude: input file hello.light.45.c.hex auto detected as Intel Hex
avrdude: input file hello.light.45.c.hex contains 426 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.77s
avrdude: verifying ...
avrdude: 426 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you. |
Now we have our board programmed.
Step 3: visualizing the data
To view the data I need to install python and Tkinter on my computer.
Now from the console in windows, placed in the folder where the downloaded file hello.light.45.py are, I write in the console:
python hello.light.45.py COM5 |
If Tkinter is successfully installed, a window on the screen with a blue and red bar that increases and decreases appear as the light sensor get in the board.
|