Lecture on Input Devices

Emma gave us a very good lecture on input devices. A slideshow can be found here.

Designing and Making a Microcontroller Board In Order to Measure Something

-

I decided to measure distance and proximity. Probably, I would need this for my final project. I would use a phototransistor and a LED to measure proximity and an ultrasonic module to measure distance. Besides, I would be able to measure light with a phototransistor only. I decided to use an ATtiny44 microcontroller because it has more pins which I would need.

Using Eagle, I started to draw my schematic. Doing the board layout from scratch was a real challenge even with 0 Ω resistors used to bridge some traces. Finally, I used the hello echo-world board sample to start from which in turn was a satisfying job.

Eagle design files

Please download the original Eagle design files here.

Photos of production

I made a mistake! Testing my microcontroller board, I determined that the serial communication didn't work properly. I tested all traces again using a multimeter without detecting a single short. We reviewed my schematic. I connected RTS and RST. I thought the sample schematic had a misspelling. Emma told me that RST and RTS are two different things. Removing the 0 Ω resistor, I disconnected RST and RTS. In the end, the serial communication worked fine. I used Neil’s hello.ftdi script in order to test it. I tested the LED with a simple Arduino blinking script as well. I tried to adjust Neil's C scripts in order to measure proximity which didn't work finally. In the evening I got an error message: My board couldn't be initialized anymore.

Programming the MCU board to measure something

I started from scratch with clean Arduino scripts. The first test was to measure light with a phototransistor again. That was done easily. To measure proximity using the LED and the phototransistor, I wrote a more complex script. Both worked fine!

In order to measure distance, I connected a HC-SR04 Ultrasonic Ranging Module to my MCU board using a cable. I followed this tutorial and installed the NewPing library as well as the NewTone library. It didn't work at all. The NewPing library was incompatible.

I did some further research and found another library here. I tested it but wasn't able to measure anything. I went home and wanted to delve into it in the evening. Setting all up and connecting my MCU board again at home, I got an error message. My MCU board couldn't be initialized anymore. Something was wrong with it. In the end, I couldn't successfully measure distance using a sonar and had to stop here.

I repaired my board replacing the ATtiny44 microcontroller. I successfully measured distance using the HC-SR04 Ultrasonic Ranging Module without any additional library. Please read more about it here.