Attiny2313 Ultrasonic distance (HR-SR04) example

As part of my robot project I need a small microcontroller to do som basic task like measuring distance using a HR-SR04 sensor. I plan to use a raspberry pi as main controller for that robot and as is runs a linux kernel is is not realtime and might be inaccurate for this application. The goal is to have the microcontroller send the measured distance over i2c to the raspberry pi.
180px-HC-SR04

The Ultrasonic module works as explained in the following diagram:

hr-sr04 timing

Lot’s of different examples regarding the HR-SR04 and microcontrollers can be found on the internet. Unfortunately a lot of them are incomplete or contain bad code. So here is yet another example :)

Below you can find a very basic schema with a attiny2313, the HR-SR04, an ISP connector and a led with a resistor.

attiny2313_hr-sr04_bb

Continue reading

Cellphone Operated Toggle Switch

Aussiemike in Kenya – who suggested that light from a mobile phone’s display screen could be used to trigger a switch. When a brief (free) phone call illuminates the display – the light from the display operates a 4017 based Toggle Switch. And any small push switch – connected in parallel with the LDR – will provide optional manual control.

Continue reading

Toggle Switch No.2

Pushing the button once will energize the relay. Pushing it a second time will de-energize the relay. Any simple momentary action push-to-make switch will do. The prototype has a single-pole relay. But you can use a multi-pole relay if it suits your application. The circuit will work at anything from 5 to 15-volts. All you need do is select a relay with a coil voltage that suits your supply.

Continue reading

Repeating Timer No.8

This circuit energizes the relay repeatedly – at regular intervals. The length of the intervals depends on the setting of R4 – and the output pin to which the “Range” wire is connected. With the range wire connected to pin 3 – intervals of up to 24-hours are available. If you need longer than 24-hours – increase the value of C3.

Continue reading