2

I just got the Arduino starter kit as my background is software developer (C++, python, etc) and I'm interested to get into the electronics side, and I love LED effects and home automation of all kinds. As such I'm quite comfortable with the type of C programming required (loops etc) but need to learn the principles of electronics.

Can you suggest any resources (websites, tutorials, books - I'm willing to pay for books if they are useful) whose focus is teaching the principles as well as doing specific projects?

The kit came with the "Arduino Projects Book" but I don't really like it as it's focused on "do this, do that, put the circuit together according to this diagram" rather than explaining the principles first. For example I did the "Spaceship Interface" (light up different LEDs in different patterns based on whether a button is pushed or not) and it introduces things like "You'll also need to add a 10k ohm resistor from ground to the switch pin that connects to the Arduino [...] it connects the pin to ground when the switch is open so it reads LOW when there is no voltage coming in through the switch". I understand that in principle I think, but why is it 10kohm, why do we have to connect it using a resistor when the switch is open, etc. (I see that we have to have a complete circuit and I'm assuming it is because the 10kohm is a "default" branch of most resistance with nothing else connected?)

I'm asking about general principles rather than the specific case of why do we have a 10kohm resistor in this case, but this is a pretty good example early in the book.

closed as primarily opinion-based by Ignacio Vazquez-Abrams, Dat Ha, Mattia, jfpoilpret, uint128_t Dec 29 '16 at 17:48

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Google is your best option! It's free and all is there. If you don't understand something, post a question on this Q&A site and maybe we can help you! – Dat Ha Dec 28 '16 at 19:38
  • 1
    Meet your new bible. – Ignacio Vazquez-Abrams Dec 28 '16 at 20:28
4

Welcome to the Arduino world!

First I'd like to try to answer your question: (This explanation does not apply to his situation as explained in the comments, but, I guess, it's a fun and useful read so I'll leave it here)

"You'll also need to add a 10k ohm resistor from ground to the switch pin that connects to the Arduino [...] it connects the pin to ground when the switch is open so it reads LOW when there is no voltage coming in through the switch". I understand that in principle I think, but why is it 10kohm, why do we have to connect it using a resistor when the switch is open, etc. (I see that we have to have a complete circuit and I'm assuming it is because the 10kohm is a "default" branch of most resistance with nothing else connected?)

I haven't seen your circuit but I think I know the deal here. The author is basically telling you to create a pull-down circuit. What this does is, what it says. It pulls down the voltage on arduino pin to GND. Now, why would you want to do that? I think because in your project, the author was reading analog values from that pin. He wants the pin pulled down because otherwise when the switch is open, the pin would be floating i.e. not connected to anything. Floating pin means that you will get random analog readings from that pin. Basically, if you don't connect that pin to any source/sink, it will act as an antenna. You will get noise. (You can actually use this to create random numbers for your arduino!)

Now, about that 10kOhm resistor: Its depends on two things. First, if you put a low value resistor, then you will draw lots of current from the supply to the ground when the switch is closed. You normally don't want that, why spend energy more than you have to? So, you pick any big resistor that you can possibly pick. But how big can you really put there? This depends on the analog read pin's current consumption. Whenever you do an ADC (analog to digital conversion) a.k.a analog read, your pin sinks/supplies tiny amounts of current and samples it to determine voltage. Atmel datasheet says that:

enter image description here

As you can see, the good guys in Atmel already did some tests and determined that with the current Atmega328p (Arduino-UNO chip) chip, a source of 10kOhm internal resistance is sampled the best. (When you open the switch, the 10kOhm resistor is basically a 0V source with 10kOhm internal resistance)So basically, I guess, that's why the author used 10kOhm. Could you have used 20kOhm instead? Of course...

Now about the electronics book thing. The best practice with electronics is to both read and do. So, whatever book you pick, make sure it has examples and explanations that you can try. Don't buy a highly theoretical book with lots of math and physics. Don't use a simple do-this do-that book either. I can't provide you a single good book, because that's not how I prefer to learn. But I might have some good suggestions for you if you prefer to study like this as well:

  • Learn the basics or R,L,C. Study filters, energy, their differential equations etc. Any book, website will do.
  • Use software and simulate theoretical/explanatory circuits. LTSpice is best. For bigger projects, something like MATLAB is better.

If you do that, you'll gain some insights on how things actually work.

  • Move on to transistors: BJT, MOSFET etc. What are they and how they behave?
  • Combine transistors and R,L,C to create some digital-analog circuits. How do you make a RAM cell? Can you make an arithmatic logic unit?

At this point, you should be comfortable with most elements of electronics.

  • Since you started with arduino, study RISC/CISC architechture. What actually is a microcontroller?
  • Since you know software, try using assembly code to turn on and off some leds. This is where you meet software and hardware at the lowest possibly level you can.
  • Try to make your own microcontroller using FPGA! (I've done this -it was a simple and not-so-useful CPU but nevertheless it provided insight. You can invent your own assembly language!!)

At this point you should be able to understand most basic arduino projects.

  • Read atmega datasheets.
  • Read Transistor, motor driver IC etc. any driver datasheet and search the terms on google. What do they mean?

After that you can do this:

  • Pick a project, and do it from scratch. Without, copying any circuits from the internet. Can you place atmega chip to work stand alone, away from arduino board? Can you use that and make for example a BLDC driver?
  • Pick a project and ask stackexchange. (Well, obviously). There are some really brilliant people here that are willing to help. Personally, I feel I'm learning better if I try to answer other peoples questions and ask questions.

I guess the downside/upside is you never stop learning. Electronics combined with software is a huge area of expertise.

So I wish you Good luck!

  • Maximus, if you look at the circuit on page 36 of Arduino Projects Book.pdf and the description on page 37 (“Attach one side to power, and the other side to digital pin 2 on the Arduino. You'll also need to add a 10k-ohm resistor from ground to the switch pin that connects to the Arduino.”) you'll see that the input is on digital pin 2, so has nothing to do with analog input. So 10KΩ source impedance being preferred for ADC inputs is totally irrelevant. 20KΩ to 50KΩ like the built-in pullups would work just fine. – James Waldby - jwpat7 Dec 29 '16 at 6:23
  • @jwpat7 Well, like I said, I didn't see the circuit. (Don't have the book) However, even if this was a digital input, the logic is similar. Because, there is an input capacitance C, which is at 5V at the time of switch release and it will be discharged through R to GND, right? So, the greater R you pick, the slower the discharge. If the discharge is slower than 1 instruction cycle, then it is possible that the arduino detects noise (because voltage around ~2.5V can be undefined). Oh and I don't think he can use internal pull-ups in that situation. Because, then he'd always get 5V on pin 2. – Maximus Dec 29 '16 at 17:08
  • But I agree with your point on ADC. That one turned out to be irrelevant. (Sorry). I'll leave the explanation there just because I think it applies very well to ADC pins and I think people might find it useful. – Maximus Dec 29 '16 at 17:09
2

I see people are voting to close this as too broad. Well, it is broad, but I'll try to give you some pointers. I used to wonder this stuff too, like "why use 10k and not 20k or 5k?". A good starting point is to watch some of Dave Jones' EEVblog videos.

For example Designing a Li-Ion Battery Gauge with the LM3914 - EEVblog #204 - this is already 5 years old. He has done a lot of them. This particular one describes using the LM3914 chip to make a battery gauge, and in the middle he works through the resistor values using Ohm's Law.

Another entertaining and informative blog is Afrotechmods. He also goes into detail but in a humorous way.

Also try M J Lorton's blog.

My only problem with videos is, if you are trying to reproduce some of their stuff you end up having to rewatch a (perhaps lengthy) video and pause it from time to time to copy stuff off the screen.

For this reason I made some posts of my own on the Electronics part of my own forum. (Some of the more popular ones are also here in Stack Exchange as reference questions, for example How do you use SPI on an Arduino?).

You could also look at the Adafruit and Sparkfun tutorials (amongst many others).

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