Tools + Methods
Roland Modela Mill
This week I decided to make an ultrasonic sensor since I need to be able to detect proximity for my final project. This sensor works just like sonar! It sends sound waves out of one of it’s little speakers and listens to hear how quickly they return. Pretty cool.
Electrical Diagram made in Eagle
Components for Sonar
I used Eagle to draw up a helloworld.HC-SR04 board. I wanted to add an LED but I didn't have any pins left on the ATTiny and I wanted to focus on just getting the sensor to work. I couldn’t find the HC-SR04 component in Eagle’s Fab Library but saw that it was four pads similar to the size of typical ISP pad so I added a 1x4 header with the intention of adding a female header or soldering the component directly to the chip.
Once again, I worked with Arduino to program my board this week. To work with the Sonar I started with this tutorial which pretty much gave me all the code I needed to work with. Essentially, you are emitting pulses from your trigPin in which your echoPin can calculate distance based on how long it takes to receive information.
Again, I set followed the high-low tech tutorial from week 6 in order to add the additional baords to the Arduino IDE. I set my board to ATTiny 25, my processor to ATTiny 45, used the default Internal 1 MHz Clock, and set my programmer to USBTinyISP. When I first ran this code it looked like it uploaded but I had no way to access the data. I needed to add serial code to read it on the Arduino plotter. I used this page to gain some more info about serial and was able to get the serial plotter to return distances in cm to me.
Final Arduino Code
Programming the board
Measuring reliable distances up to 15inches (~40 cm) away