Paperback
-
PICK UP IN STORECheck Availability at Nearby Stores
Available within 2 business hours
Related collections and offers
Overview
Publisher's Note: Products purchased from Third Party sellers are not guaranteed by the publisher for quality, authenticity, or access to any online entitlements included with the product.
Program Your Own MicroPython projects with ease—no prior programming experience necessary!
This DIY guide provides a practical introduction to microcontroller programming with MicroPython. Written by an experienced electronics hobbyist, Python for Microcontrollers: Getting Started with MicroPython features eight start-to-finish projects that clearly demonstrate each technique. You will learn how to use sensors, store data, control motors and other devices, and work with expansion boards. From there, you’ll discover how to design, build, and program all kinds of entertaining and practical projects of your own.
• Learn MicroPython and object-oriented programming basics
• Explore the powerful features of the Pyboard, ESP8266, and WiPy
• Interface with a PC and load files, programs, and modules
• Work with the LEDs, timers, and converters
• Control external devices using serial interfaces and PWM
• Build and program a let ball detector using the 3-axis accelerometer
• Install and program LCD and touchsensor expansion boards
• Record and play sounds using the AMP audio board
Product Details
ISBN-13: | 9781259644535 |
---|---|
Publisher: | McGraw Hill LLC |
Publication date: | 11/17/2016 |
Pages: | 288 |
Sales rank: | 236,513 |
Product dimensions: | 5.90(w) x 8.90(h) x 0.70(d) |
About the Author
Donald Norris (Barrington, New Hampshire) is an avid electronics hobbyist and maker. He is an engineer by formal training but has acquired a comprehensive background in software development in the past 20 years. Don is also an adjunct professor at Southern New Hampshire University and the author of Raspberry Pi Projects for the Evil Genius, Programming the Intel Edison: Getting Started with Processing and Python, and three other TAB books.
Table of Contents
Preface xi
Acknowledgments xiii
1 Introduction 1
Introduction to MicroPython 1
Design Philosophy 1
Exploring MicroPython 2
Object-Oriented Programming and Some Python Basics 3
Object-Oriented Concepts 4
Modeling a Robot 7
Some Python Basics 9
The Robot Class 11
Child Classes 12
Using Interfaces 14
Integrated Robot Project Design and Test 15
Dynamic Binding 18
Using MicroPython with a Pyboard 21
Bare-Metal Approach 23
Summary 25
2 Introduction to the Pyboard 27
Pyboard Hardware 27
Generic Microcontroller Program Development 30
Interrupts 31
Controlling the Pyboard 33
Python Test Program 36
Blinking LEDs 37
PyBlink 38
PyBlink_MP 39
Hardware Interrupt Demonstration 40
Emergency Exception Buffer 42
Timers 43
Timer Interrupts 44
Other Pyboard Hardware 45
The ADC 45
The DAC 47
Summary 53
3 Interfaces, Files, and Libraries 55
Pulse Width Modulation 55
Bit-Serial Ports 57
UART Serial Protocol 57
I2C Serial Protocol 63
SPI Serial Protocol 64
Directory Structures 67
Importing a Module 68
Using a File for an Import 68
Importing a Module from a PYBFLASH Subdirectory 70
Using the SD Card for an Import 71
Boot Process 72
Error Reporting by the LEDs 73
Libraries 74
Standard Libraries 74
Customized Python Libraries 74
Pyboard-Specific Library and Classes 75
MicroPython Library 76
Summary 77
4 Let Ball Detector 79
Initial Design 80
Project Requirements 80
Prototype 81
The Accelerometer 83
Low-Level 12C Command Demonstration 88
Inclinometer 90
Hardware Design 91
Main Program 96
Experimenting on the Tennis Court 100
Turn On Visual and Optional Audio Alerts upon Let Ball Detection 101
Final Program 102
Summary 102
5 LCD and Touch-Sensor Board 105
LCD Board Specifications 106
Initial LCD Module Operations 107
LCD Graphics Demonstration 111
Using an External Command with the LCD Controller 112
Touch Controller 113
Capacitive Sensing 114
LCD Module Touch-Sensor Schematic and MPR121 Registers 115
MPR121 Driver Software 117
Initial Touch-Sensor Test 118
LEDs Controlled by Touch Pads 119
LCD and Touch-Sensor Demonstration 122
Using the LCD Module GPIO Pins 124
MPR121PWM 128
Summary 131
6 The AMP Audio Skin 133
Assembling the AMP Board 133
AMP Board Circuits 135
Audio Input Circuit 137
Audio Output Circuit 141
Initial Test 144
Troubleshooting the Distortion 144
Playing MP3 Files 150
Audio Input Demonstration 151
Summary 153
7 An Autonomous Robotic Car 155
Building the Robot Car Platform 155
A Standard Analog Servo 156
CR Servo 159
Robotic Car Power Supply 160
Electrical and Wiring Instructions 162
Ping Sensor 163
Robot Car Software 165
CR Servo Control 165
Initial Test Run 167
Autonomous Mode 168
Obstacle Avoidance Demonstration 173
Summary 175
8 GPS with the Pyboard 177
Introduction 177
Brief GPS History 177
The Basics of How GPS Functions 178
The Ultimate GPS Receiver 184
Initial GPS Receiver Test 185
GPS Receiver UART Communication 188
NMEA Protocol 192
Latitude and Longitude Formats 193
Parsed GPS Message 194
MicroPython GPS Parser 195
Preparing GPS Sentences for Parsing 196
Summary 199
9 The ESP8266 201
The ESP8266 SMT ESP-12E Module 201
The ESP8266 HUZZAH Breakout Board 204
Key Hardware Technical ESP8266 Features 205
ESP8266 Software 208
Installing MicroPython on the HUZZAH ESP8266 Board 208
Exploring MicroPython Installed on the ESP8266 HUZZAH Board 210
Experiments 213
Analog-to-Digital Converter 214
1-Wire Temperature Sensor 216
NeoPixel Demonstration 220
APA102 Demonstration 223
WEBREPL 226
Summary 228
10 The WiPy 229
WiPy Specifications 229
Wi-Fi Modes 231
Station 231
Access Point 231
Direct 232
WiPy Expansion Board 232
Creating the Initial WiPy Network Connection 237
FTP Demonstration 240
FileZilla 242
Station Operation 244
Boot Process and Restoring the Filesystem 246
Restoring the Filesystem 247
Pymakr 248
Summary 250
11 Current and Future States of MicroPython 251
The MicroPython Language 251
Hardware Platforms 253
LoPy 253
LoRa Radio System 254
SiPy 256
Sigfox versus LoRa 257
Summary 257
Index 259