1

Please I'm new to Arduino and I need assistance. I'm working on a project which makes use of the ultrasonic sensor to make a certain pin high if a certain distance is attained. When I used the USB port to power it up it worked fine. When I use external power(tried two different 9V microphone battery) it's not giving desired result. Now I want to try using just the Atmega328P on the board externally(separately from the Arduino).

Questions

  1. What could be the cause of the malfunction when I use external 9V battery
  2. what voltage should I connect to the VCC of the Atmega cos I'm scared of damaging it.
  3. Am I going to power the ultrasonic sensor with an entirely different source from the VCC or I can tap from that same VCC source.
  4. Any other information I need to know using the ATmega on its own

closed as unclear what you're asking by per1234, sempaiscuba, Greenonline, MatsK, gre_gor Jul 11 '18 at 16:33

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

1.8 - 5.5V (max)

The datasheet (http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_Summary.pdf) will tell you that input Voltage is: 1.8 - 5.5V

That's max of 5.5V so don't use 9V battery without a voltage divider. To power the chip all you need is voltage to Pin 7 and GND to PIN 8.

16Mhz Crystal Most Likely Required

However, to get it to work after removing the chip from an Arduino Uno board you will also need a 16Mhz Crystal on pins 9 & 10. You will also need two 22pF capacitors on pins 9 & 10, each connected to ground.

I've written this all up with pictures at my blog: http://raddev.us/arduino/post/2018/07/03/arduino-uno-using-your-atmega328p-u-as-stand-alone

Your final circuit will look something like the following (from my blog article): with crystal

Without the Crystal you will most likely find that your sketches don't seem to run.

Note: The red LED is connected just as a blink test (more on that in the article).

  • 1
    Thank you very much. I really appreciate your response. Would try everything out. – user169847 Jul 10 '18 at 20:13
  • 3
    A voltage divider is not a regulator, don't try to power a chip with a divider! – esoterik Jul 10 '18 at 20:39
  • Okay, good point. But was only attempting to mention that 9V was too much. So are you saying that if he divided the voltage down to 3.3V for example and applied that voltage (which is in the range that the chip can handle) it would cause some kind of problem? – raddevus Jul 10 '18 at 21:26
  • 2
    @raddevus a voltage divider doesn't regulate, as the load changes so will the voltage, a stable voltage is required to run a micro controller. – esoterik Jul 10 '18 at 23:37
1

What you need is a voltage regulator! There are many options to choose from linear regulators to buck (or boost) DC-DC converter. You can buy them from various sources as well.

What could be the cause of the malfunction when I use external 9V battery?

The ATMega can only handle 5V maximum, using 9V will either destroy it or engage protection circuitry that will prevent the chip from operating and being damaged.

What voltage should I connect to the VCC of the Atmega?.

Most of the time an ATMega is powered with 5V, but depending on the clock frequency they can operate at lower voltages, the datasheet will have the details.

Am I going to power the ultrasonic sensor with an entirely different source from the VCC or I can tap from that same VCC source?

With the appropriate choice of powersupply you can power both the AVR chip and your sensor with the same power supply.

Any other information I need to know using the ATmega on its own?

The datasheet will contain all you need to know, but if you want to use the Arduino tool chain you will need to:

  • Use an external crystal
  • Burn the Arduino (or AvrDUDE) bootloader
  • I can't conclude which of the questions you are helping me answer. – user169847 Jul 10 '18 at 20:29
  • 1
    @user169847 I edited the answer to be more clear – esoterik Jul 10 '18 at 20:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.