Input devices
This week we had to visualized on the computer the reading of the sensor .I used a light sensor.
first I milld the board (traces,interior) and solder the components.
Then I conected the light sensor board to the Fabisp and programed it using the terminal for the code.
For visualization I usedArduino and processing.
First I started with Arduino and used the photocell exampel to write the code.
After that I opened the prosesnig program and selected the hue exampel.
I modified it so when there's light the bars would change colors and when there's no light the bars would stop moving.
After I used processing to visualize I dictated to program the board with python.
first you need to install Pyserial You will need the following files:
hello.light.45.c
hello.light.45.make
hello.light.45.py
To program the Board
sudo make -f hello.light.45.make program-usbtiny
Terminal Output When Board is Being programd
[sudo] password for omerayal: 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.
Run The Python Program
Your serial port may be different depending on your computer. You need to find the port for your computer. To find your serial port, with the board attached:, in terminal - type
ls /dev/tty.usb*
Then use the port you are given to run the python program. For example - when I type "ls /dev/tty.usb*", I get "/dev/tty.usbserial-FTG67J88". So I would type:
python hello.light.45.py /dev/tty.usbserial-FTG67J88
The Graph should now pop up on your screen.