Brand



WEEK 13 – INPUT DEVICE





Weekly assignment

Add a sensor to a microcontroller board that you have designed and read it



For this week's assignment I made the hello.HC-SR04 board


BOM


Designing the board


As usual I started designing it on Eagle


foto11
foto11

I only changed the pin header using a 2x2 to connect the sensor (HC-SR04 V1.0)


Programming the board


After soldered and connected the board to my FabISP I started to program. Before to do this I downloaded Neil's C code and .make file adjusting it to my project


foto11

When I moved to type the make-program I recieved an error


foto11

But I only had to repeat the command and it worked


foto11

I didn't set the fuses because this time I didn't use an external clock as I did in my previous boards, but the ATtiny45 internal clock (8MHz)


Programming With Python


Before this week I didn't know what Python was, so I needed to read something about it

My instructor suggested me this tutorial wich was foundamental. And with a big help of my classmate Simone I've been able to get the job done


First thing I downloaded Neil's python file and I made it executable by typing the command in my terminal

But when I moved to launch it I recieved an error...


foto11

The command is not found because I typed "./" as a link to the current folder, but in the .py file there wasn't the line wich defines that file as a python

Then I added that line on the top (the first blu line in the document)


foto11

Otherwise I could type the command "python dist_sensor.py" without that line and it would work well


But when I repeated the command I recieved another error...


foto11

The message ask to install the python-tk package. So I did it


foto11

Then I had to find the serial port wich the FTDI was connected...


foto11

...because when I tried to launch the python file I recieved a notification that told me that the right command to type includes the serial port


foto11

And also another one that asked for superior permission


Finally I was able to launch the python file and then to recieve a visual feedback of the device working


foto11
foto11

Eagle and programming files here

Licenza Creative Commons

This work is licensed under a Creative Commons Attribution - ShareAlike 4.0 International License