Arduino and external peripherals

I am a CS guy who started working with Arduino. This is probably a very simple electronics question, but going to the arduino tutorials is all about arduino with a resistor.

Well, since I follow the tutorials, I know what type of resistor I should use, but what I don't know is why should I use it? and What type of resistor to choose, I have to do something that is not covered in the textbook.

+4
source share
3 answers

The resistor simply serves to limit the current to or from the pin in case something goes wrong. If your AVR decides to output high on the pin that something else wants to low (or vice versa), large, damaging currents may occur if not limited by some resistance. The current limit for the AVR is about 20 milliamps, and given that voltages are usually 5 V, something larger than 250 ohms should work.

To provide a margin of safety, 1-10k is an excellent choice; for digital signals, this rarely matters unless you are using high-speed applications (in any case, other than AVR capabilities). For analog inputs, it is advisable to use a similar resistor, since the amount of current that the ADC receives per sample is negligible if your resistor is in the range of several kilograms.

+8
source

The basic principle you want to study is Ohm's Law , which describes the relationship between voltage, resistance, and current in a circuit.

+6
source

Resistors are used to

  • current limit
  • devide voltage
  • surge protection
  • pull-up, pull down
  • current to voltage conversion
  • etc.

1) the maximum output current, the absolute maximum current at IO is 40 mA, a typical LED works at ± 2 V 20 mA.
the resistance value can be calculated (5 V - 2 V) / (0.02 A) = 150 Ohms, a 220 Ohm resistor is usually used because: it consumes less energy, 20 milliamps do not flow, and there is no noticeable difference in the emitted light.

2) if you have an analog voltage that varies from 0 to 10 volts, you will need a 1/2 voltage divider. select the z2 10k example and calculate z1 at 10k * (Vin, max / 5V -1). take the resistance value above the source. and recount the new Vout.

3) put a 10k resistor in series between the arduino analog input and “measure voltage”

3) if you need to measure the analog current, you install the resistor to ground and the analog input, calculate the resistor at Z = 5 V / ampere.

4) if you connect the button to the arduino, you will need to pull or pull out the resistor. if you do not use a resistor, the input is floating and can take any value (high or low). or you can turn on the internal weak pull-up. by pinMode (xx, INPUT); digitalWrite (xx, HIGH) ;. and disabeling by digitalWrite (xx, LOW); pull-up is disabled by default.

+5
source

All Articles