Python for microcontrollers getting started with micropython

282 281 0
Python for microcontrollers  getting started with micropython

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Copyright © 2017 by McGraw-Hill Education All rights reserved Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher ISBN: 978-1-25-964454-2 MHID: 1-25-964454-5 The material in this eBook also appears in the print version of this title: ISBN: 978-1-25-964453-5, MHID: 1-25-964453-7 eBook conversion by codeMantra Version 1.0 All trademarks are trademarks of their respective owners Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark Where such designations appear in this book, they have been printed with initial caps McGraw-Hill Education eBooks are available at special quantity discounts to use as premiums and sales promotions or for use in corporate training programs To contact a representative, please visit the Contact Us page at www.mhprofessional.com Information has been obtained by McGraw-Hill Education from sources believed to be reliable However, because of the possibility of human or mechanical error by our sources, McGraw-Hill Education, or others, McGraw-Hill Education does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from the use of such information TERMS OF USE This is a copyrighted work and McGraw-Hill Education and its licensors reserve all rights in and to the work Use of this work is subject to these terms Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill Education’s prior consent You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited Your right to use the work may be terminated if you fail to comply with these terms THE WORK IS PROVIDED “AS IS.” McGRAW-HILL EDUCATION AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE McGraw-Hill Education and its licensors not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free Neither McGraw-Hill Education nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom McGraw-Hill Education has no responsibility for the content of any information accessed through the work Under no circumstances shall McGraw-Hill Education and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise This book is dedicated to my three wonderful grandchildren, Hudson and Holton Norris and Evangeline Kachavos They are an absolute joy to be with, although I am sure that sentiment is not always shared by their parents About the Author Donald Norris has a degree in electrical engineering and an MBA specializing in production management He is currently teaching undergrad and grad courses in the IT subject area at Southern New Hampshire University He has also created and taught several robotics courses there He has over 36 years of teaching experience as an adjunct professor at a variety of colleges and universities Mr Norris retired from civilian government service with the U.S Navy, where he specialized in acoustics related to nuclear submarines and associated advanced digital signal processing Since then, he has spent more than 22 years as a professional software developer using C, C#, C++, Python, Node.js, and Java, as well as years as a certified IT security consultant Mr Norris started a consultancy, Norris Embedded Software Solutions (dba NESS LLC), that specializes in developing application solutions using microprocessors and microcontrollers He likes to think of himself as a perpetual hobbyist and geek, and is always trying out new approaches and outof-the-box experiments He is a licensed private pilot, photography buff, amateur radio operator, and avid runner Besides the present book, Mr Norris is 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 CONTENTS Preface Acknowledgments Introduction Introduction to MicroPython Design Philosophy Exploring MicroPython Object-Oriented Programming and Some Python Basics Object-Oriented Concepts Modeling a Robot Some Python Basics The Robot Class Child Classes Using Interfaces Integrated Robot Project Design and Test Dynamic Binding Using MicroPython with a Pyboard Bare-Metal Approach Summary Introduction to the Pyboard Pyboard Hardware Generic Microcontroller Program Development Interrupts Controlling the Pyboard Python Test Program Blinking LEDs PyBlink PyBlink_MP Hardware Interrupt Demonstration Emergency Exception Buffer Timers Timer Interrupts Other Pyboard Hardware The ADC The DAC Summary Interfaces, Files, and Libraries Pulse Width Modulation Bit-Serial Ports UART Serial Protocol I2C Serial Protocol SPI Serial Protocol Directory Structures Importing a Module Using a File for an Import Importing a Module from a PYBFLASH Subdirectory Using the SD Card for an Import Boot Process Error Reporting by the LEDs Libraries Standard Libraries Customized Python Libraries Pyboard-Specific Library and Classes MicroPython Library Summary Let Ball Detector Initial Design Project Requirements Prototype The Accelerometer Low-Level I2C Command Demonstration Inclinometer Hardware Design Main Program Experimenting on the Tennis Court Turn On Visual and Optional Audio Alerts upon Let Ball Detection Final Program Summary LCD and Touch-Sensor Board LCD Board Specifications Initial LCD Module Operations LCD Graphics Demonstration Using an External Command with the LCD Controller Touch Controller Capacitive Sensing LCD Module Touch-Sensor Schematic and MPR121 Registers MPR121 Driver Software Initial Touch-Sensor Test LEDs Controlled by Touch Pads LCD and Touch-Sensor Demonstration Using the LCD Module GPIO Pins MPR121 PWM Summary The AMP Audio Skin Assembling the AMP Board AMP Board Circuits Audio Input Circuit Audio Output Circuit Initial Test Troubleshooting the Distortion Playing MP3 Files Audio Input Demonstration Summary An Autonomous Robotic Car Building the Robot Car Platform A Standard Analog Servo CR Servo Robotic Car Power Supply Electrical and Wiring Instructions Ping Sensor Robot Car Software CR Servo Control Initial Test Run Autonomous Mode Obstacle Avoidance Demonstration Summary GPS with the Pyboard Introduction Brief GPS History The Basics of How GPS Functions The Ultimate GPS Receiver Initial GPS Receiver Test GPS Receiver UART Communication NMEA Protocol Latitude and Longitude Formats Parsed GPS Message MicroPython GPS Parser Preparing GPS Sentences for Parsing Summary The ESP8266 The ESP8266 SMT ESP-12E Module The ESP8266 HUZZAH Breakout Board Key Hardware Technical ESP8266 Features ESP8266 Software Installing MicroPython on the HUZZAH ESP8266 Board Exploring MicroPython Installed on the ESP8266 HUZZAH Board Experiments Analog-to-Digital Converter 1-Wire Temperature Sensor NeoPixel Demonstration APA102 Demonstration webREPL Summary 10 The WiPy WiPy Specifications driver software for, 117 –118 initial test for, 118 –119, 119 f for LCD, 106 PWM and, 128 –130, 129 t , 130 f registers for, 115 –117, 116 f my_sentence , 196 myFrame , GPS and UART and, 62 , 192 myFrame = bytearray(63) , 191 –192 N Nano editor: with Linux, 36 RasPi and, 11 National Marine Electronics Association (NMEA), GPS and, 178 , 192 –195, 193 t NeoPixel, 200 f , 213 –222, 221 f , 221 t , 222 f Nested vectored interrupt controller (NVIC), 33 Network class, in pyb library, 76 Newton's second law of motion, 84 NMEA See National Marine Electronics Association NPN transistor, for let ball detector, 94 NVIC See Nested vectored interrupt controller O Object Land, , f Object-oriented (OO): constructors in, 13 DPs and, interrupts and, 31 –33 lambda and, 41 Python and, –7, Object-oriented programming (OOP), –7 principles of, t scope in, Obstacle avoidance software, for autonomous robotic car, 168 –173, 169 f , 169 t demonstration of, 173 –174, 174 f 1-Wire protocol, for ESP8266 HUZZAH breakout board, 216 –220, 217 f OO See Object-oriented OOP See Object-oriented programming Op-amp See Operational amplifier Operating system (OS): FileZilla and, 242 MicroPython as, , 24 , 39 –40 Operational amplifier (op-amp), for AMP audio skin electret microphone, 139 –140, 140 f Orientation, axes of, for MMA7660FC, 85 –86, 86 f OS See Operating system Os library, 74 os.getcwd() , 71 P Parallax, 155 –156 Parent attributes, protected scope and, Parent class, in parentheses, 13 Parentheses ( ), parent class in, 13 Parser, of MicroPython: automatic parsing with, 198 for GPS, 194 –195 manual parsing with, 196 –197, 197 t Pc See Program counter PCB See Printed circuit board perform_move() , 12 perform_sense() , 12 Pin class, in pyb library, 76 Pin sockets, on Pyboard, 33 –34, 34 f PinAF class, in pyb library, 76 Ping sensor, for autonomous robotic car, 163 –165, 163 f , 164 f pinX1.value() == , 37 Pixels: for LCD, 106 –107 polarization of, for LCD, 112 Points of view (POVs), for MicroPython, 252 Polarization, of pixels, for LCD, 112 Polymorphism: dynamic binding and, 20 in OOP, f Potentiometer: for AMP audio skin, 141 –142, 142 f for autonomous robotic car analog servo, 157 –159 POVs See Points of view Power supply: for autonomous robotic car, 160 –162, 160 f Ping sensor of, 164 for ESP8255 ESP12E module, 203 t for ESP8266 HUZZAH breakout board, 204 –205 for Pymakr, 249 for STM microcontroller, 30 t for WiPy expansion board, 232 , 234 X5 pin and, 48 Pre-amplifier, for AMP audio skin electret microphone, 139 –140, 140 f Printed circuit board (PCB): for ADC, 214 for APA102 LED module, 223 –224 for LCD, 106 for let ball detector, 92 Private scope (−), Program counter (pc), 32 Propeller Activity Board, 156 Protected scope, Prototype, for let ball detector, 81 –99, 82 f case attached to net, 92 , 92 f hardware for, 91 –99 steel cover for, 91 –92, 92 f Pseudo-random noise, on DAC on Pyboard, 51 , 52 f Public scope (+), Pulse width modulation (PWM): of autonomous robotic car analog servo, 158 –159 CCW and, 55 , 129 CR for autonomous robotic car, 159 GPIO and, 129 MicroPython and, autonomous robotic car and, 165 MPR 121 and, 128 –130, 129 t , 130 f on Pyboard, 55 –56, 56 f PushButton, GPIO and, 38 Put command, FTP, 240 t PuTTY, 237 Pwd command, FTP, 240 t PWM See Pulse width modulation pyb.LED(1).off() , 35 pyb.LED(1).on() , 34 Pyb library, 37 , 75 –76 Acceleration class of, 88 ADC in, 45 classes in, 76 I2C class in, 117 I2C serial protocol in, 64 SPI in, 65 UART in, 58 , 61 , 76 PYBFLASH, 22 , 22 f , 36 , 40 , 67 , 68 f AMP audio skin and, 144 , 150 module importing and, 70 –71, 70 f , 71 f MPR121 and, 119 PyBlink, 38 –39 PyBlink_MP, 39 –40 Pyboard, 21 f , 27 –53 See also AMP audio skin; Autonomous robotic car; Global positioning system; Let ball detector accelerometer on: GPIO for, 87 , 101 I2C protocol for, 86 , 86 f , 88 –90 for let ball detector, 80 , 83 –88, 83 f ADC on, 45 –47, 151 , 153 bit-serial ports on, 57 –66 boot process for, 72 –73 callback function for, 45 controlling, 33 –36 CS0 pin on, for ESP8255 ESP12E module, 203 t DAC on, 47 –52 linearity measurements for, 48 , 48 f , 48 t pseudo-random noise on, 51 , 52 f REPL and, 50 sine wave on, 49 –50, 49 f , 50 f triangular wave and, 50 –51, 51 f generic microcontroller program development and, 30 –37 GND pin on: for ESP8255 ESP12E module, 203 t for GPS, 187 for let ball detector, 93 hard fault condition for, 74 hardware, 27 –29, 28 f , 29 t , 30 t I2C serial protocol, 63 –64, 63 f , 63 t for accelerometer, 86 , 86 f , 88 –90 for LCD, 107 in pyb library, 76 REPL for, 88 –90, 118 for WiPy, 230 t integrated chips on, 29 , 29 t interrupts on, 31 –33 demonstration of, 40 –42 triggers for, 33 LCD, 105 –131, 105 f , 110 f back side of, 106 external command for, 112 –113 graphics demonstration for, 111 –112, 112 f Hello World for, 109 I2C serial protocol for, 107 initial module operations of, 107 –111 methods for, 110 t mounting of, 106 –107, 107 f , 108 f , 109 f in pyb library, 76 specifications for, 106 –107 LEDs on, 33 , 34 –35, 34 t blinking, 37 –40, 44 –45 for boot process, 72 error reporting by, 73 –74 GPIO and, 35 –36, 35 f , 36 f for let ball detector, 79 , 82 , 94 , 94 f , 95 f PWM and, 56 MicroPython and, –2, 21 –23 GPS parser and, 195 module importing into, 68 –72, 69 f pin-out diagram for, 46 f pin sockets on, 33 –34, 34 f PWM on, 55 –56, 56 f RST pin on: for ESP8255 ESP12E module, 203 t for ESP8266 HUZZAH breakout board, 205 RST push button on, 40 for boot process, 72 RX pin on, 57 , 57 t for ESP8266 HUZZAH breakout board, 205 uart and, 62 UART GPS and, 60 for Ultimate GPS receiver, 191 RXD0 pin on, for ESP8255 ESP12E module, 203 t schematic for, 28 f SCL pin on, for Pyboard accelerometer, 87 SPI on, 64 –66, 65 f , 65 t STM microcontroller on, 29 , 29 t , 30 t EXTI and, 32 interrupts and, 31 –33, 42 –43 IRQs and, 32 LEDs and, 38 NVIC on, 33 timers on, 43 3V3 pin on, 46 –47, 46 f UART GPS and, 60 timers on, 43 –45 interrupts for, 44 –45 TX pin on, 57 , 57 t uart and, 62 UART GPS and, 60 for Ultimate GPS receiver, 191 TXD pin on, for GPS, 60 , 187 TXD0 pin on, for ESP8255 ESP12E module, 203 t UART on, 57 –62, 57 f , 57 t GPS and, 59 –62, 59 f , 60 f , 61 f USR push button on, 40 –41 for boot process, 72 VIN pin on, 93 X1 pin on, 46 –47, 46 f for accelerometer, 101 for autonomous robotic car, 165 for let ball detector, 101 for Python test program, 37 X2 pin on: for accelerometer, 101 for autonomous robotic car, 165 for LEDs, 36 for let ball detector, 101 for Python test program, 37 X5 pin on: for autonomous robotic car obstacle avoidance software, 170 DAC and, 47 LEDs and, 179 power supply and, 48 SPI and, 65 t X6 pin on: DAC and, 47 SPI and, 65 t X7 pin on, 65 t X8 pin on, 65 t X9 pin on, for accelerometer, 87 Y5 pin on, 65 t Y6 pin on, 65 t Y7 pin on, 65 t Y8 pin on, 65 t Pycom: LoPy by, 253 –254, 254 f Pymakr by, 248 –250, 248 f , 249 f WiPy by, 229 –250 access point Wi-Fi mode for, 231 –232 boot process for, 246 –247, 247 t direct Wi-Fi mode for, 232 expansion board for, 232 –237, 233 f , 234 t , 236 t filesystem restoring for, 247 –248 FileZilla and, 242 –243, 243 f , 244 f FTP for, 239 –242, 239 f , 240 t network connection for, 237 –239 SiPy and, 256 –257, 256 f specifications of, 229 , 230 f , 230 t station Wi-Fi mode for, 231 , 244 –246 Wi-Fi modes of, 231 –232 PyCon See Python Conference PYFLASH: for autonomous robotic car, 167 LCD in, 111 MicroPython GPS parser and, 195 Pymakr, WiPy and, 248 –250, 248 f , 249 f Python: = (assignment operator) in, basics of, –11 import statements in, 17 inheritance in, 13 interfaces in, 14 –15 lambda and, 41 libraries for: customized, 74 –75 specifically for, 75 –76 standard, 74 line-by-line interpreter for, 24 logo for, f methods and, 37 OO and, –7, scripts in, 11 test program for, 36 –37 variables in, 10 python , in Raspberry Pi, –10 Python Conference (PyCon), Q Quick Connect, on FileZilla, 243 R Radio-control (RC), analog servo for, 156 –159 Radiofrequency (RF): for ESP8266, 205 for GPS, 182 LoRa for, 254 –255, 256 t Random access memory (RAM), 23 AMP audio skin and, 150 for emergency exception buffer, 77 for ESP8266, 205 for WiPy, 230 t Random noise generator (RNG), 30 t Raspberry Pi (RasPi), AMP audio skin and, 150 nano editor and, 11 python in, –10 for UART GPS, 60 , 61 Raspian Linux, nano editor and, 11 RC See Radio-control Read-eval-print-loop (REPL), 23 for AMP audio skin, 144 , 150 audio input for, 151 for APA102 LED module, 225 for axes of acceleration, 96 –97 CWD and, 71 DAC on Pyboard and, 50 debugging and, 73 debugging with, 73 for ESP8266 HUZZAH breakout board, 210 –211, 226 –227, 227 f for I2C protocol, 88 –90, 118 lcddemogpio.py and, 128 for MicroPython parser, 198 module importing and, 69 for Pyboard LEDs, 34 UART GPS and, 61 for Ultimate GPS receiver, 190 USR push button and, 40 –41 WebREPL, 226 –227, 227 f for WiPy, 237 in station Wi-Fi mode, 245 README.txt, 22 , 22 f Real-time clock (RTC), 30 t class, in pyb library, 76 for WiPy, 230 t recv , 58 Regular expressions, 75 Rename command, FTP, 240 t REPL See Read-eval-print-loop RF See Radiofrequency Rmdir command, FTP, 240 t RNG See Random noise generator Robotic car See Autonomous robotic car Robots: child classes for, 12 –13 classes for, 11 –13 defined, dynamic binding for, 18 –21, 20 f integrated project design and test for, 15 –18, 16 f , 17 f interfaces for, 14 –15 modeling of, –9, f UML and, –8, f , 15 –18, 16 f RST pin: for ESP8255 ESP12E module, 203 t for ESP8266 HUZZAH breakout board, 205 RST push button, 40 for boot process, 72 RTC See Real-time clock RX pin, 57 , 57 t for ESP8266 HUZZAH breakout board, 205 uart and, 62 UART GPS and, 60 for Ultimate GPS receiver, 191 RXD, for ESP8266 HUZZAH breakout board, 208 RXD0 pin, for ESP8255 ESP12E module, 203 t S Samples per second (SPS), 216 SCL pin, 87 SCLK See Serial clock Scope, in OOP, Scripts, in Python, 11 SD card, 23 for let ball detector, 98 –99, 102 for module importing, 71 –72, 72 f for WiPy expansion board, 232 , 234 t SDA See Serial data SDIO See Secure digital input/output Secure digital input/output (SDIO), 30 t Select library, 74 Sense, in UML, 11 SenseBehavior, 15 SenseWithPing, 15 Sensors, in robots, Serial clock (SCLK), 63 for ESP8255 ESP12E module, 203 t Serial data (SDA), 63 Serial Peripheral Interface (SPI): in pyb library, 76 on Pyboard, 64 –66, 65 f , 65 t Service set identifier (SSID), 231 Servo See also Analog servo CR, 165 –167 Servo class, in pyb library, 76 set_move_behavior(self, mb) , 18 set_sense_behavior(self, sb) , 18 Sigfox, 257 Sine wave: for AMP audio skin, 147 , 149 f on DAC on Pyboard, 49 –50, 49 f , 50 f SiPy, 256 –257, 256 f Slave addresses, in I2C serial protocol, 64 SoC See System-on-a-chip Socket module, 75 Software interrupts (SWIs), 32 spi , 66 SPI See Serial Peripheral Interface SPS See Samples per second SSID See Service set identifier SSL/TLS, for WiPy, 230 t StartExtendedSenseOnTheFly , 19 StartRapidMoveOnTheFly , 19 Station Wi-Fi mode, for WiPy, 231 , 244 –246 STM microcontroller, 29 , 29 t , 30 t EXTI and, 32 interrupts and, 31 –33, 42 –43 IRQs and, 32 LEDs and, 38 NVIC on, 33 timers on, 43 Strong typing, 11 Struct library, 74 sw = pyb.Switch() , 40 SWIs See Software interrupts Switch class, 40 in pyb library, 76 Synchronous serial interface See Serial Peripheral Interface Sys library, 74 sys.path , 67 , 67 f System-on-a-chip (SoC), for ESP8266, 205 T Telnet, WiPy and, 237 –249, 238 f Text editors, 11 , 36 Third harmonic distortion (THD), 142 , 148 3-Axis Orientation/Motion Detection Sensor See MMA7660FC accelerometer 3V3 pin, 46 –47, 46 f UART GPS and, 60 Time library, 74 Timer class: in MicroPython, 43 in pyb library, 76 TimerChannel class, in pyb library, 76 Timers, on Pyboard, 43 –45 interrupts for, 44 –45 Touch pads, for LED, 119 –122, 120 f , 121 f Touch-sensor board, for LCD, 105 –131, 105 f capacitors for, 114 –115, 115 f demonstration of, 122 –124, 123 f , 124 f GPIO for, 115 , 124 –128, 125 f initial test for, 118 –119, 119 f registers for, 115 –117, 116 f schematic for, 115 –117, 115 f tracked.perform_sense() , 20 TrackedRobot, 12 , 13 , 17 , 20 Traps, 32 Triangular wave, DAC on Pyboard and, 50 –51, 51 f TX pin, 57 , 57 t uart and, 62 UART GPS and, 60 for Ultimate GPS receiver, 191 TXD pin, for GPS, 60 , 187 TXD0 pin, for ESP8255 ESP12E module, 203 t TypeError: unsupported type for operator , 238 U , 62 , 191 UART See Universal Asynchronous Receive Transmit uart.any() , 58 uart.deinit() , 58 uart.readinto(buf) , 58 uart.readinto(myFrame) , 191 , 198 Ubinascii, 75 Uctypes, 75 Uhashlib, 75 Uheapq, 75 Ujson, 75 Ultimate GPS receiver, 184 f initial receiver test for, 185 –188, 187 f REPL for, 190 UART for, 184 , 185 , 188 –192 uart Unified Modeling Language (UML): interfaces and, 14 –15, 14 f move in, 11 robots and, –8, f , 15 –18, 16 f sense in, 11 Universal Asynchronous Receive Transmit (UART): in pyb library, 76 on Pyboard, 57 –62, 57 f , 57 t GPS and, 59 –62, 59 f , 60 f , 61 f for STM microcontroller, 30 t for Ultimate GPS receiver, 184 , 185 , 188 –192 Ure, 75 USB_VCP class, in pyb library, 76 Usocket, 75 USR push button, 40 –41 for boot process, 72 Uzlib, 75 V , 47 Variables, in Python, 10 Verbose command, FTP, 240 t VIN pin, on Pyboard for let ball detector, 93 Vlissides, John, 18 , 18 n Volt-ohm meter (VOM), 48 val = adc.read() W wav, AMP audio skin and, 150 WebREPL, for ESP8266 HUZZAH breakout board, 226 –227, 227 f wheeled.perform_move() , 20 WheeledRobot, 12 –13, 17 , 20 MoveWithWheels for, 14 –15, 14 f Wi-Fi: ESP8266 and, 207 modes of, for WiPy, 231 –232 WiPy, 229 –250 access point Wi-Fi mode for, 231 –232 boot process for, 246 –247, 247 t direct Wi-Fi mode for, 232 expansion board for, 232 –237, 233 f , 234 t , 236 t filesystem restoring for, 247 –248 FileZilla and, 242 –243, 243 f , 244 f FTP for, 239 –242, 239 f , 240 t Pymakr and, 248 –250, 248 f , 249 f SiPy and, 256 –257, 256 f specifications of, 229 , 230 f , 230 t station Wi-Fi mode for, 231 , 244 –246 telnet and, 237 –249, 238 f Wi-Fi modes of, 231 –232 wipy-wlan-0526 , 237 Wireless public key (WPK), 231 WIZNET5K class, in pyb library, 76 WPA, for WiPy, 230 t , 237 WPK See Wireless public key write_timed () , 49 , 50 WS2812, for NeoPixel, 220 X X1 pin, 46 –47, 46 f for accelerometer, 101 for let ball detector, 101 for Python test program, 37 X2 pin, 37 for accelerometer, 101 for autonomous robotic car, 165 for LEDs, 36 for let ball detector, 101 for Python test program, 37 X5 pin: for autonomous robotic car obstacle avoidance software, 170 DAC and, 47 LEDs and, 179 power supply and, 48 SPI and, 65 t X6 pin: DAC and, 47 SPI and, 65 t X7 pin, 65 t X8 pin, 65 t X9 pin, for accelerometer, 87 XCode, 36 Y Y5 pin, 65 t Y6 pin, 65 t Y7 pin, 65 t Y8 pin, 65 t Z Zlib decompression, 75 ... George at www .micropython. org for his excellent efforts in creating the MicroPython language and getting the Pyboard out to the marketplace 1 Introduction This book is about the MicroPython language;... hosting MicroPython as an operating system (OS) Dr George subsequently presented MicroPython, version 1.0, at a 2014 Python Conference (PyCon) Dr George also started the website micropython. org... OO, Python basics, and a recommended software design approach It is now time to start using MicroPython Using MicroPython with a Pyboard The simplest and quickest way to start using MicroPython

Ngày đăng: 02/03/2019, 10:19

Từ khóa liên quan

Mục lục

  • Title Page

  • Copyright

  • Dedication

  • About the Author

  • Contents

  • Preface

  • Acknowledgments

  • 1 Introduction

    • Introduction to MicroPython

    • Design Philosophy

    • Exploring MicroPython

    • Object-Oriented Programming and Some Python Basics

      • Object-Oriented Concepts

      • Modeling a Robot

      • Some Python Basics

      • The Robot Class

      • Child Classes

      • Using Interfaces

      • Integrated Robot Project Design and Test

      • Dynamic Binding

      • Using MicroPython with a Pyboard

      • Bare-Metal Approach

Tài liệu cùng người dùng

Tài liệu liên quan