The objective is to make the vibration's intensity change with the distance measured. I got the coding part down but when I connect arduino for the upload it doesnt even power on. I think this is due to the fact that all the components draw too much current from the 5V pin of the arduino.
I'm thinking about powering the haptic motors and driver externally but don't exactly know how to do it, can anybody help?
Arduinos are NOT a power source. You will need an external power source. A typical choice would be a "wall wart" or the type you use to charge your phone or USB charger. You will need one that can supply 5V and several amps. It will need to be connected to the 5V pin on your Arduino (not Vin) as well as all the other power pins for your sensors/motors. You need to connect all the grounds together as well.
It is always best to to verify your power supply is delivering 5V before you use it on your arduino, since some wall chargers deliver much more than 5V, even when rated as 5V
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
Do you have a DMM? (Digital MultiMeter)
Try uploading with the hardware disconnected.
Did you write your code in stages?
Do you have code JUST to test the I2C?
Do you have code the JUST reads the range sensor?
If no, then please write a series of simple codes to test each of your peripherals, please do not try and code it all at once.
This will help you with future designs: Gil's Crispy Critter Rules for Processor Hardware:
Rule #1: An Arduino is NOT a Power Supply!
Rule #2: Never connect anything inductive (motors, speakers) directly to an Arduino!
Rule #3: Avoid connecting or disconnecting wires while the power is on.
Rule #4: Do not apply power to any pin unless you are certain of what you're doing.
Rule #5: Do not exceed the maximum voltage ratings.
Rule #6: Many Arduinos cannot power transmitters directly.
Rule #7: Before powering your project, take a break and double-check the wiring.
LaryD’s Corollaries:
Coro #1: When starting out, add a 220Ω resistor in series with both input and output pins to protect against shorts.
Coro #2: Invest in a Digital Multi-Meter (DMM) to measure voltages, currents, and resistance.
Note: Violating these rules can turn your Arduinos into crispy critters. For optimal performance, keep your wires under 25 cm (10 inches).
Additional Tips:
The L293 motor driver, though common, is inefficient as it can lose around 3V as heat when driving both legs of a motor. Consider using a motor driver with MOSFET outputs to reduce heat loss and conserve battery power.
Hi!
Tanks for the clarification, however I need my project to be able to be carried around, I cannot therefore use a wall outlet to power my sensor and motors. I'm trying to figure out how to use a battery pack as in the picture
Connecting everything to the same ground I found no problem with. But why would I connect the power pack to the 5v pin? Doesn't the pin supply 5v to whatever is connected to it?
It all depends on your design. If your power supply is 6-9V then you supply it to the arduino through the barrel jack or Vin which goes through the regulator to make it 5V for the board.
If your power supply is already a 5V regulated supply, you do not feed it to the on-board regulator because the regulator requires a voltage above 6V in order to properly regulate. In that case you feed it directly into the +5V pin on the board.