万本电子书0元读

万本电子书0元读

顶部广告

MicroPython Cookbook电子书

售       价:¥

42人正在读 | 0人评论 6.2

作       者:Marwan Alsabbagh

出  版  社:Packt Publishing

出版时间:2019-05-21

字       数:46.5万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Learn how you can control LEDs, make music, and read sensor data using popular microcontrollers such as Adafruit Circuit Playground, ESP8266, and the BBC micro:bit Key Features * Load and execute your first program with MicroPython * Program an IoT device to retrieve weather data using a RESTful API * Get to grips with integrating hardware, programming, and networking concepts with MicroPython Book Description MicroPython is an open source implementation of Python 3 that runs in embedded environments. With MicroPython, you can write clean and simple Python code to control hardware instead of using complex low-level languages like C and C++. This book guides you through all the major applications of the MicroPython platform to build and program projects that use microcontrollers. The MicroPython book covers recipes that’ll help you experiment with the programming environment and hardware programmed in MicroPython. You’ll find tips and techniques for building a variety of objects and prototypes that can sense and respond to touch, sound, position, heat, and light. This book will take you through the uses of MicroPython with a variety of popular input devices and sensors. You’ll learn techniques for handling time delays and sensor readings, and apply advanced coding techniques to create complex projects. As you advance, you’ll get to deal with Internet of Things (IoT) devices and integration with other online web services. Furthermore, you'll also use MicroPython to make music with bananas and create portable multiplayer video games that incorporate sound and light animations into the game play. By the end of the book, you'll have mastered tips and tricks to troubleshoot your development problems and push your MicroPython project to the next level! What you will learn * Execute code without any need for compiling or uploading using REPL (read-evaluate-print-loop) * Program and control LED matrix and NeoPixel drivers to display patterns and colors * Build projects that make use of light, temperature, and touch sensors * Configure devices to create Wi-Fi access points and use network modules to scan and connect to existing networks * Use Pulse Width Modulation to control DC motors and servos * Build an IoT device to display live weather data from the Internet at the touch of a button Who this book is for If you want to build and program projects that use microcontrollers, this book will offer you dozens of recipes to guide you through all the major applications of the MicroPython platform. Although no knowledge of MicroPython or microcontrollers is expected, a general understanding of Python is necessary to get started with this book.
目录展开

About Packt

Why subscribe?

Packt.com

Contributors

About the author

About the reviewers

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Sections

Getting ready

How to do it…

How it works…

There's more…

See also

Get in touch

Reviews

Getting started with MicroPython

What is MicroPython?

What is a microcontroller?

What is CircuitPython?

What is the Circuit Playground Express?

Where to buy

References

Flashing the microcontroller firmware

Getting ready

How to do it...

How it works...

There's more...

See also

Executing your first program

Getting ready

How to do it...

How it works...

There's more...

See also

Using screen to access the REPL

Getting ready

How to do it...

How it works...

There's more...

See also

Using Mu to access the REPL

Getting ready

How to do it...

How it works...

There's more...

See also

Executing commands in the REPL

Getting ready

How to do it...

How it works...

There's more...

See also

Using the auto-reload feature

Getting ready

How to do it...

How it works...

There's more...

See also

Updating the CircuitPython Library

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling LEDs

The Adafruit Circuit Playground Express layout

Turning on the pin 13 LED

Getting ready

How to do it...

How it works...

There's more...

See also

Setting the brightness of the NeoPixel

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling the color of a single NeoPixel

Getting ready

How to do it...

How it works...

There's more...

See also

Displaying an LED color using the RGB and hex code

Getting ready

How to do it...

How it works...

There's more...

See also

Setting an LED color using color names

Getting ready

How to do it...

How it works...

There's more...

See also

Setting all NeoPixels to the same color

Getting ready

How to do it...

How it works...

There's more...

See also

Setting a range of NeoPixels to one color

Getting ready

How to do it...

How it works...

There's more...

See also

Generating random NeoPixel LED colors

Getting ready

How to do it...

How it works...

There's more...

See also

Creating LED animations with random colors

Getting ready

How to do it...

How it works...

There's more...

See also

Creating LED animations with rainbow colors

Getting ready

How to do it...

How it works...

There's more...

See also

Creating Sound and Music

The Adafruit Circuit Playground Express layout

Making a beeping sound

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling tone, frequency, and duration

Getting ready

How to do it...

How it works...

There's more...

See also

Playing a musical note

Getting ready

How to do it...

How it works...

There's more...

See also

Playing a melody

Getting ready

How to do it...

How it works...

There's more...

See also

Sounding the alarm

Getting ready

How to do it...

How it works...

There's more...

See also

Playing WAV files

Getting ready

How to do it...

How it works...

There's more...

See also

Converting MP3 files to WAV files

Getting ready

How to do it...

How it works...

There's more...

See also

Starting and stopping tones

Getting ready

How to do it...

How it works...

There's more...

See also

Interacting with Buttons

The Adafruit Circuit Playground Express layout

Detecting push button presses

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling LEDs with push buttons

Getting ready

How to do it...

How it works...

There's more...

See also

Reading a slide switch

Getting ready

How to do it...

How it works...

There's more...

See also

Calling functions on the button state change

Getting ready

How to do it...

How it works...

There's more...

See also

Moving active LEDs with push buttons

Getting ready

How to do it...

How it works...

There's more...

See also

Playing a beep on the button press

Getting ready

How to do it...

How it works...

There's more...

See also

Detecting touch on a touchpad

Getting ready

How to do it...

How it works...

There's more...

See also

Monitoring the touchpad raw measurements

Getting ready

How to do it...

How it works...

There's more...

See also

Adjusting the touch threshold

Getting ready

How to do it...

How it works...

There's more...

See also

Reading Sensor Data

Circuit Playground Express sensors

Reading temperature readings

Getting ready

How to do it...

How it works...

There's more...

See also

Reading brightness levels from the light sensor

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a light meter

Getting ready

How to do it...

How it works...

There's more...

See also

Reading data from the motion sensor

Getting ready

How to do it...

How it works...

There's more...

See also

Detecting a single or double tap

Getting ready

How to do it...

How it works...

There's more...

See also

Detecting a shake

Getting ready

How to do it...

How it works...

There's more...

See also

Beeping on a shake

Getting ready

How to do it...

How it works...

There's more...

See also

Button Bash Game

Technical requirements

Circuit Playground Express power

Creating a class to detect a button state change

Getting ready

How to do it...

How it works...

There's more...

See also

Creating your own Python modules

Getting ready

How to do it...

How it works...

There's more...

See also

Adding button interactions to the event loop

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a generator to get pixel colors

Getting ready

How to do it...

How it works...

There's more...

See also

Showing scores with the ScoreBoard class

Getting ready

How to do it...

How it works...

There's more...

See also

Detecting winners with the ScoreBoard class

Getting ready

How to do it...

How it works...

There's more...

See also

Adding the ScoreBoard class to the event loop

Getting ready

How to do it...

How it works...

There's more...

See also

Fruity Tunes

Technical requirements

Circuit Playground Express touchpads

Creating a class to react to touch events

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a function to enable speaker output

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a function to play audio files

Getting ready

How to do it...

How it works...

There's more...

See also

Using the NeoPixel object to control pixels

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a touch handler to play sounds

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a touch handler to light up pixels

Getting ready

How to do it...

How it works...

There's more...

See also

Creating an event loop to handle all touch events

Getting ready

How to do it...

How it works...

There's more...

See also

Let's Move It, Move It

Technical requirements

DC motors

Servos

Adafruit CRICKIT

Where to buy

Tuning a servo to the correct pulse width

Getting ready

How to do it...

How it works...

There's more...

See also

Setting the actuation range of a servo

Getting ready

How to do it...

How it works...

There's more...

See also

Setting the angle of a servo

Getting ready

How to do it...

How it works...

There's more...

See also

Sweeping a servo

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling servos with buttons

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling multiple servos

Getting ready

How to do it...

How it works...

There's more...

See also

Turning on a DC motor

Getting ready

How to do it...

How it works...

There's more...

See also

Setting the speed and direction of a DC motor

Getting ready

How to do it....

How it works...

There's more...

See also

Controlling a DC motor with buttons

Getting ready

How to do it...

How it works...

There's more...

See also

Coding on the micro:bit

Technical requirements

The micro:bit

Using Mu to flash code onto the micro:bit

Getting ready

How to do it...

How it works...

There's more...

See also

Using Mu to get a REPL on the micro:bit

Getting ready

How to do it...

How it works...

There's more...

See also

Displaying a single character on the LED display

Getting ready

How to do it...

How it works...

There's more...

See also

Displaying a built-in image

Getting ready

How to do it...

How it works...

There's more...

See also

Displaying scrolling text

Getting ready

How to do it...

How it works...

There's more...

See also

Showing which button has been pressed

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a countdown timer

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling the ESP8266

Technical requirements

The Adafruit Feather HUZZAH ESP8266

Where can you buy these?

Using the REPL over a serial connection

Getting ready

How to do it...

How it works...

There's more...

See also

Scanning for available Wi-Fi networks

Getting ready

How to do it...

How it works...

There's more...

See also

Configuring settings for AP mode

Getting ready

How to do it...

How it works...

There's more...

See also

Connecting to an existing Wi-Fi network

Getting ready

How to do it...

How it works...

There's more...

See also

Using the WebREPL over Wi-Fi

Getting ready

How to do it...

How it works...

There's more...

See also

Transferring files with the WebREPL CLI

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling the blue and red LEDs

Getting ready

How to do it...

How it works...

There's more...

See also

Interacting with the Filesystem

Technical requirements

Remounting the filesystem

Getting ready

How to do it...

How it works...

There's more...

See also

Listing files

Getting ready

How to do it...

How it works...

There's more...

See also

Removing files

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a directory

Getting ready

How to do it...

How it works...

There's more...

See also

Reading a file's contents

Getting ready

How to do it...

How it works...

There's more...

See also

Writing a file's contents

Getting ready

How to do it...

How it works...

There's more...

See also

Calculating disk usage

Getting ready

How to do it...

How it works...

There's more...

See also

Networking

Technical requirements

Performing a DNS lookup

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a function to wait for internet connectivity

Getting ready

How to do it...

How it works...

There's more...

See also

Performing an HTTP request using raw sockets

Getting ready

How to do it...

How it works...

There's more...

See also

Performing an HTTP request using the urequests library

Getting ready

How to do it...

How it works...

There's more...

See also

Fetching JSON data from a RESTful web service

Getting ready

How to do it...

How it works...

There's more...

See also

Creating an HTTP server

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a web handler module

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling LEDs through the web server

Getting ready

How to do it...

How it works...

There's more...

See also

Developing a RESTful API to control the LEDs

Getting ready

How to do it...

How it works...

There's more...

See also

Interacting with the Adafruit FeatherWing OLED

The Adafruit FeatherWing OLED

Where to buy it

Technical requirements

Detecting button presses with GPIO pins

Getting ready

How to do it...

How it works...

There's more...

See also

Connecting to the SSD1306 display

Getting ready

How to do it...

How it works...

There's more...

See also

Filling and clearing the display

Getting ready

How to do it...

How it works...

There's more...

See also

Setting pixels on the display

Getting ready

How to do it...

How it works...

There's more...

See also

Drawing lines and rectangles on the display

Getting ready

How to do it...

How it works...

There's more...

See also

Writing text on the display

Getting ready

How to do it...

How it works...

There's more...

See also

Inverting colors on the display

Getting ready

How to do it...

How it works...

There's more...

See also

Building an Internet of Things (IoT) Weather Machine

Technical requirements

Retrieving weather data from the internet

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a function to get a city's weather

Getting ready

How to do it...

How it works...

There's more...

See also

Randomly selecting cities

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a Screen object for text handling

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a function to show a city's weather

Getting ready

How to do it...

How it works...

There's more...

See also

Providing visual feedback when fetching data

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a function to display the weather for a random city

Getting ready

How to do it...

How it works...

There's more...

See also

Creating an IoT button to show the weather around the world

Getting ready

How to do it...

How it works...

There's more...

See also

Coding on the Adafruit HalloWing Microcontroller

The Adafruit HalloWing M0 Express

Where to buy

Technical requirements

Discovering I2C devices

Getting ready

How to do it...

How it works...

There's more...

See also

Reading data from the accelerometer using I2C

Getting ready

How to do it...

How it works...

There's more...

See also

Detecting board-flipping with the accelerometer

Getting ready

How to do it...

How it works...

There's more...

See also

Controlling screen brightness

Getting ready

How to do it...

How it works...

There's more...

See also

Displaying a bitmap image

Getting ready

How to do it...

How it works...

There's more...

See also

Listing all image files

Getting ready

How to do it...

How it works...

There's more...

See also

Creating a joke-telling machine

Getting ready

How to do it...

How it works...

There's more...

See also

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部