183: Digital Electronics: Microcontrollers Ready To Use.

Take Up Code - A podcast by Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes

Categories:

Unlike microprocessors, microcontrollers can be used all by themselves. If you’re building a computer, then go ahead and use a microprocessor. But almost anything else that’s not entirely mechanical will probably need a microcontroller. Maybe even several. If it has buttons, then it can use a microcontroller. If it monitors temperature, or light, or position, then it can use a microcontroller. If it records information, or drives a display, or communicates with another device, then it can use a micro controller. A microcontroller is really just a single chip containing a microprocessor, memory, and input and output ports. Most microcontrollers will have more components such as analog-to-digital converters, comparators, pulse-width modulation, and communications. What you’re not going to find on a microcontroller are address lines or data lines. These are all contained inside the microcontroller. What’s exposed to the outside world is ready for you to use. Listen to the full episode to learn more about the additional features as well as some examples of how you can use a microcontroller. You can also read the full transcript below. Transcript If you’re building a computer, then go ahead and use a microprocessor. But almost anything else that’s not entirely mechanical will probably need a microcontroller. Maybe even several. If it has buttons, then it can use a microcontroller. If it monitors temperature, or light, or position, then it can use a microcontroller. If it records information, or drives a display, or communicates with another device, then it can use a microcontroller. Make sure to listen to the previous episode about microprocessors. I try not to repeat things as much as possible and instead will refer you to other episodes. I’m going to compare microcontrollers with microprocessors to help you understand microcontrollers better. A microcontroller is really just a single chip containing a microprocessor, memory, and input and output ports. Most microcontrollers will have more components such as analog-to-digital converters, comparators, pulse-width modulation, and communications. What you’re not going to find on a microcontroller are address lines or data lines. These are all contained inside the microcontroller. What’s exposed to the outside world is ready for you to use. Let’s say that you want to control some lights by turning them on and off in some interesting pattern. All you have to do is figure out which ports you want to use and connect each port to a light. This assumes that the lights can be driven directly from the microcontroller. If the lights need more current than the microcontroller can supply, then you might need to use other components such as transistors. I’ll explain transistors in a future episode. Each port is a pin on the microcontroller and can be configured to be an output port or an input port. To control things such as lights, you’ll want to use output ports. If you want to monitor a switch or a button to know when somebody pushes it, then you can can connect the button to a port configured as an input port. The biggest difference between ports and data lines relates to timing. Data lines on a microprocessor constantly send and receive data that has to be timed exactly. Ports though maintain their values when configured for output until your code decides to change the value. And input ports are ready to handle that button press at any time. You can connect a microcontroller to the lights so that when a port value is high, then the light is on and when the port value is low, then the light is off. What about all those other features that microcontrollers usually have included? First let’s look at the memory. There’ll be two different kinds of memory. One is flash memory. That’s where the microcontroller holds the code that you write. You program a microcontroller just like a microprocessor. But instea