Fab Academy 2013

Input Devices

Phototransistor

Electronics production

phototransistor   phototransistor

Components needed to build the Hello Light board are:

* 2 Resistences: 10k and 49.9k

* 1 Capacitor 1uF

* 1 ISP connector

* 1 Attiny45

* 1 FTDI connector

*1 Phototransistor

Programming the board

Flashing the board with AVR ISP. First attempt "Error 1" because the microcontroller was not totally in contact with boards trace. Once this was fixed everything goes ok.

 
          Last login: Mon May  6 13:21:15 on console

mora-pc:Fabacademy2013 sara$ cd Assig10_Input_devices/
mora-pc:Assig10_Input_devices sara$ ls
2013-05-02 18.28.30.avi		2013-05-03 20.52.15.jpg
2013-05-03 17.20.45.jpg		2013-05-03 20.52.34.jpg
2013-05-03 17.20.51.jpg		2013-05-03 20.53.18.jpg
2013-05-03 17.21.01.jpg		2013-05-03 20.53.28.jpg
2013-05-03 17.21.10.jpg		2013-05-03 20.53.51.jpg
2013-05-03 17.42.34.jpg		hello.light.45.c
2013-05-03 17.42.43.jpg		hello.light.45.c.hex
2013-05-03 17.42.50.jpg		hello.light.45.interior.png
2013-05-03 17.44.00.jpg		hello.light.45.jpg
2013-05-03 17.44.04.jpg		hello.light.45.make
2013-05-03 18.26.23.jpg		hello.light.45.out
2013-05-03 19.21.15.jpg		hello.light.45.png
2013-05-03 20.52.08.jpg		hello.light.45.traces.png
mora-pc:Assig10_Input_devices sara$ sudo make -f hello.light.45.make program-usbtiny
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
avr-objcopy -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:     530 bytes (12.9% Full)
(.text + .data + .bootloader)

Data:          1 bytes (0.4% Full)
(.data + .bss + .noinit)


avrdude -p t45 -P usb -c usbtiny -U flash:w:hello.light.45.c.hex
avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)

avrdude done.  Thank you.

make: *** [program-usbtiny] Error 1
mora-pc:Assig10_Input_devices sara$ sudo make -f hello.light.45.make program-ATAVRISP2
make: *** No rule to make target `program-ATAVRISP2'.  Stop.
mora-pc:Assig10_Input_devices sara$ sudo make -f hello.light.45.make program-atavrisp2
make: *** No rule to make target `program-atavrisp2'.  Stop.
mora-pc:Assig10_Input_devices sara$ sudo make -f hello.light.45.make program-avrisp2
avr-objcopy -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:     530 bytes (12.9% Full)
(.text + .data + .bootloader)

Data:          1 bytes (0.4% Full)
(.data + .bss + .noinit)


avrdude -p t45 -P usb -c avrisp2 -U flash:w:hello.light.45.c.hex

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

make: *** [program-avrisp2] Error 1
mora-pc:Assig10_Input_devices sara$ sudo make -f hello.light.45.make program-avrisp2
Password:
avr-objcopy -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:     530 bytes (12.9% Full)
(.text + .data + .bootloader)

Data:          1 bytes (0.4% Full)
(.data + .bss + .noinit)


avrdude -p t45 -P usb -c avrisp2 -U flash:w:hello.light.45.c.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

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 (530 bytes):

Writing | ################################################## | 100% 0.19s

avrdude: 530 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 530 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.17s

avrdude: verifying ...
avrdude: 530 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

mora-pc:Assig10_Input_devices sara$ 
                 
   

Installing PySerial

Following Anna's tutorial I downloaded the PySerial and installed it:

 
 MacBook-de-Sara-Alvarellos:~ sara$ ls
Applications
Desktop
Documents
Downloads
Dropbox
Google Drive
Library
Maker_Show_Zaragoza_2013_02_22_PIEME37.pdf
Movies
Music
Pictures
Public
Sites
bruselas estef despedida.pdf
hg
MacBook-de-Sara-Alvarellos:~ sara$ cd Documents
MacBook-de-Sara-Alvarellos:Documents sara$ ls
2011					coche 2.JPG
2012					coche1.JPG
Arduino					cv porfolios becas
Dibujos					dcdcity
Empresasygestion			eagle
Gestiones				fotoserasmus
IMG_20130405_212442.jpg			grasshopper
Introtocircuits1.pdf			introtocircuits.pdf
Introtocircuits2.pdf			perfilidentidadigital
Introtocircuits3.jpg			processing pruebas
Introtocircuits3.pdf			processing-1.4.1.min.js
Libraries				pruebas htacces
PendienteLeer				pyserial-2.5
Processing				pyserial-2.5.tar.tar.gz
Sara Alvarellos Fab Academy 2013.pdf	scratch
Scratch Projects			untitled_0.odt
UKELELE					web
cesar
MacBook-de-Sara-Alvarellos:Documents sara$ cd pyserial-2.5
MacBook-de-Sara-Alvarellos:pyserial-2.5 sara$ sudo python setup.py install
Password:
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/serial
copying serial/__init__.py -> build/lib/serial
copying serial/loopback_connection.py -> build/lib/serial
copying serial/rfc2217.py -> build/lib/serial
copying serial/serialcli.py -> build/lib/serial
copying serial/serialjava.py -> build/lib/serial
copying serial/serialposix.py -> build/lib/serial
copying serial/serialutil.py -> build/lib/serial
copying serial/serialwin32.py -> build/lib/serial
copying serial/sermsdos.py -> build/lib/serial
copying serial/socket_connection.py -> build/lib/serial
copying serial/win32.py -> build/lib/serial
running build_scripts
creating build/scripts-2.6
copying and adjusting examples/miniterm.py -> build/scripts-2.6
changing mode of build/scripts-2.6/miniterm.py from 644 to 755
running install_lib
creating /Library/Python/2.6/site-packages/serial
copying build/lib/serial/__init__.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/loopback_connection.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/rfc2217.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/serialcli.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/serialjava.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/serialposix.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/serialutil.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/serialwin32.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/sermsdos.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/socket_connection.py -> /Library/Python/2.6/site-packages/serial
copying build/lib/serial/win32.py -> /Library/Python/2.6/site-packages/serial
byte-compiling /Library/Python/2.6/site-packages/serial/__init__.py to __init__.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/loopback_connection.py to loopback_connection.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/rfc2217.py to rfc2217.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/serialcli.py to serialcli.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/serialjava.py to serialjava.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/serialposix.py to serialposix.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/serialutil.py to serialutil.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/serialwin32.py to serialwin32.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/sermsdos.py to sermsdos.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/socket_connection.py to socket_connection.pyc
byte-compiling /Library/Python/2.6/site-packages/serial/win32.py to win32.pyc
running install_scripts
copying build/scripts-2.6/miniterm.py -> /usr/local/bin
changing mode of /usr/local/bin/miniterm.py to 755
running install_egg_info
Writing /Library/Python/2.6/site-packages/pyserial-2.5-py2.6.egg-info
MacBook-de-Sara-Alvarellos:pyserial-2.5 sara$ 
 

Running the hello.light.45.py

1. Connecting the board to the computer with a FTDI. 2. From the assigment fabacademy site I dowloaded the hello.light.45.py file. I open the terminal and I went to the right directory where this file was saved. Once at the right directory, in my case was "examples" at the "pyserial-2.5" folder; I typed:
 
python hello.light.45.py /dev/tty.usbserial-FTFD96P8
. To know what usb connection my computer was using I opened Arduino ide and have a look at the serial ports active at that moment: /dev/tty.usbserial-FTFD96P8. Below all the process to run the hello.light.45.py from the terminal.
 

Last login: Mon Jul 29 11:43:58 on ttys000
MacBook-de-Sara-Alvarellos:~ sara$ ls
Applications
Desktop
Documents
Downloads
Dropbox
Google Drive
Library
Maker_Show_Zaragoza_2013_02_22_PIEME37.pdf
Movies
Music
Pictures
Public
Sites
bruselas estef despedida.pdf
hg
MacBook-de-Sara-Alvarellos:~ sara$ cd Documents/
MacBook-de-Sara-Alvarellos:Documents sara$ ls
2011					coche 2.JPG
2012					coche1.JPG
Arduino					cv porfolios becas
Dibujos					dcdcity
Empresasygestion			eagle
Gestiones				fotoserasmus
IMG_20130405_212442.jpg			grasshopper
Introtocircuits1.pdf			introtocircuits.pdf
Introtocircuits2.pdf			perfilidentidadigital
Introtocircuits3.jpg			processing pruebas
Introtocircuits3.pdf			processing-1.4.1.min.js
Libraries				pruebas htacces
PendienteLeer				pyserial-2.5
Processing				pyserial-2.5.tar.tar.gz
Sara Alvarellos Fab Academy 2013.pdf	scratch
Scratch Projects			untitled_0.odt
UKELELE					web
cesar
MacBook-de-Sara-Alvarellos:Documents sara$ cd pyserial-2.5
MacBook-de-Sara-Alvarellos:pyserial-2.5 sara$ ls
CHANGES.txt	PKG-INFO	documentation	setup.py
LICENSE.txt	README.txt	examples	test
MANIFEST.in	build		serial
MacBook-de-Sara-Alvarellos:pyserial-2.5 sara$ cd examples
MacBook-de-Sara-Alvarellos:examples sara$ ls
enhancedserial.py		setup-miniterm-py2exe.py
hello.light.45.py		setup-rfc2217_server-py2exe.py
miniterm.py			setup-wxTerminal-py2exe.py
port_publisher.py		tcp_serial_redirect.py
port_publisher.sh		wxSerialConfigDialog.py
rfc2217_server.py		wxSerialConfigDialog.wxg
scan.py				wxTerminal.py
scanlinux.py			wxTerminal.wxg
scanwin32.py
MacBook-de-Sara-Alvarellos:examples sara$ python hello.light.45.py /dev/tty.usbserial-FTFD96P8

 

That's how it works:

When our hand is far from the phototransistor the visualitation goes like on this image:

When our hand is next to the phototransistor the visualitation goes like on this image: