00:26 Thirdly, that output. This can be sent in the form of a motor spinning, an LED lighting up, a counter changing, a message being sent, or anything else that can be controlled via electronic or electrical means.
00:47 What is a microcontroller? You may know that a microcontroller is small and not as powerful as the computer on your desktop or in your server rack. What you may not know is microcontrollers are all around you, adding intelligence and control to your devices.
01:02 They’re embedded in everything from appliances and home security setups to pacemakers, heating and ventilation systems, and more. Microcontrollers do relatively simple things day after day, reliably, and in a compact package.
01:16 They compress a CPU, memory, and IO into one general-purpose chip, rather than requiring whole boards of chips that team up to perform a task. The code that they run is called firmware, which is flashed or burned onto writeable memory before executing.
01:33 While there are those of us who grew up with early microcomputers like the ZX Spectrum and Commodore Vic20 and may find these chips unbelievably powerful, you actually have more power available in your smartwatch.
01:59 Why MicroPython? These microcontrollers were proliferating long before MicroPython existed, so what benefits will it bring you over traditional practices? Well, first, the language is more accessible to beginners than competing languages, while still being powerful enough for industrial use cases.
02:18 You can go from learning the basics to doing real work, and do so quickly. Secondly, Python allows for rapid feedback. This is because you can interactively enter commands and get a response using the REPL.
Last, the wealth of Python code and experience out there means that you can do some things more quickly and easily as a Python programmer. Libraries such as
json make handling complex tasks simple that would be extremely difficult to do in other languages.
02:56 What about C++? Well, on the upside, C++ is fast, it’s compact, and it’s ubiquitous. It’s available everywhere, and there are tons of C++ programmers out there and a rich community of Arduino and PIC developers ready to help you.
03:15 Isn’t it a better choice? Well, there’s more to it than that. On the downsides of C++ compared to Python, development speed is often slower. It’s very quick to write code in Python, as we will see soon, and there is a steep learning curve to learning C++. It’s nowhere near as forgiving or easy to understand as Python is. Thirdly, C++ code can be extremely complex. Implementing identical functionality in Python can be quicker, simpler, and easier to understand.
03:59 So, here, you’re going to see three programs, all of which do the same thing, which is calculate the terms of the Fibonacci sequence. So, this first one is written in Assembler, and due to the way that Assembler works, every single instruction for the processor needs to be explicitly stated.
04:32 Compare that with the version written in C. Here, the program’s written in C, and it’s comprehensible even without comments. However, it’s not as prosaic as the final version we’re going to take a look at, which of course is in Python.
04:48 The Python version is concise and readable, even without any comments. This demonstrates one of the reasons for developing with Python. The code can be simple to create, easy to debug, comprehensible in the future, and extendable if needs be. In the next lesson, you’ll take a look at the hardware your Python code can run on.
Become a Member to join the conversation.