That's good, do you know what you did different to make it work?kalmar79 wrote:ok I did again in another file and working good
You have two ways to go.kalmar79 wrote:I want to introduce a buzzer insted a led. do I need to modificate something?
1) is with a 5V sounder with built-in driving circuitry.
2) A piezo type sounder which requires a driving waveform e.g. PWM.
Due to age of your microcontroller, it does not have any useful functions built-in .
E.e. PWM, analogue to digital converters, internal oscillator etc.
So with that in mind the second option is possible but is complex.
This is because of the need to be bit banged while sill allowing detection function.
So with your chip, option one would be easiest as you just put 5V DC in and it will buzz.
If the buzzer takes more than the current that a pin can supply then you will required an additional transistor for controlling power to the buzzer.
How the Proximity detector works is a pulse of 10us is sent into the trigger pulse input which causes a burst of ultrasonic sound to be generated.kalmar79 wrote:Why you use '320' in (Echo = 0) || (count > 320) ??
Then the microcontroller waits for a signal caused by receiving sound wave that was generated by the trigger.
So its waiting in a tight loop.
What if the sound is not received back?
Then it will stay stuck in a tight loop.
Code: Select all
count > 320
If the signal is not received within a few milliseconds then exit tight loop and resend trigger pulse.