This week is about measuring something with a sensor on a board with an atmel attiny 45 microcontroller (jeeej, another datasheet to read!). I chose to do a light sensor because I would like to use it for my final project, and a transmitter/receiver step response sensor because I was curious how it works.
Light sensor - step by step
Milling and stuffing the board - we're getting comfortable with that!
Programming the board in the terminal.
These are the steps:
- connect the board to the ISP programmer, and connect both via their usb to the computer
- download the .make, .c and .py files for the light sensor from the input devices class page
- cd (put in the folder where you stored the .make, .c and .py files)
- make -f hello.light.45.make > composes the hex file that the microcontroller can read - sudo make -f hello.light.45.make program-usbtiny > programs the chip - python hello.light.45.py /dev/tty.usbserial FTF3GVPD > opens the terminal that shows the value of the sensor.
Note that you must not program the fuses like in the embedded programming assignment, since the board does not use an external crystal.
Reading the sensor: when light hits the sensor it returns a low value, without light it gives a high value.
Transmitter /receiver - step by step
Milling and soldering the board
Making copper pieces and sticking them to a surface
Programming the board in the terminal. These are the steps:
- connect the board to the ISP programmer, and connect both via their usb to the computer
- download the .make, .c and .py files for the light sensor from the input devices class page
- cd (put in the folder where you stored the .make, .c and .py files)
- make -f hello.txrx.45.make > composes the hex file that the microcontroller can read - sudo make -f hello.txrx.45.make program-usbtiny > programs the chip - python hello.txrx.45.py /dev/tty.usbserial FTF3GVPD > opens the terminal that shows the value of the sensor.
Again, don't program the fuses like in the embedded programming assignment, since the board does not use an external crystal.
Reading the sensor
When you come close with your finger to the copper sheets (but don't touch it) the sensor value increases. The value range is between 1800 and 2300 approximately, so the effect is less visible compared to the light sensor.
The python programme was hanging a couple of times - I couldn't quit it anymore. A good trick was to close the programme via the terminal with the command ctrl c.