Python Programming for Arduino
eBook - ePub

Python Programming for Arduino

Pratik Desai

Partager le livre
  1. 400 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Python Programming for Arduino

Pratik Desai

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Python Programming for Arduino est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Python Programming for Arduino par Pratik Desai en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Programming Languages. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2015
ISBN
9781783285938

Python Programming for Arduino


Table of Contents

Python Programming for Arduino
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with Python and Arduino
Introduction to Python
Why we use Python
When do we use other languages
Installing Python and Setuptools
Installing Python
Linux
Ubuntu
Fedora and Red Hat
Windows
Mac OS X
Installing Setuptools
Linux
Windows
Mac OS X
Installing pip
Installing Python packages
The fundamentals of Python programming
Python operators and built-in types
Operators
Built-in types
Data structures
Lists
Tuples
Sets
Dictionaries
Controlling the flow of your program
The if statement
The for statement
The while statement
Built-in functions
Conversions
Math operations
String operations
Introduction to Arduino
History
Why Arduino?
Arduino variants
The Arduino Uno board
Installing the Arduino IDE
Linux
Mac OS X
Windows
Getting started with the Arduino IDE
What is an Arduino sketch?
Working with libraries
Using Arduino examples
Compiling and uploading sketches
Using the Serial Monitor window
Introduction to Arduino programming
Comments
Variables
Constants
Data types
Conversions
Functions and statements
The setup() function
The loop() function
The pinMode() function
Working with pins
Statements
Summary
2. Working with the Firmata Protocol and the pySerial Library
Connecting the Arduino board
Linux
Mac OS X
Windows
Troubleshooting
Introducing the Firmata protocol
What is Firmata?
Uploading a Firmata sketch to the Arduino board
Testing the Firmata protocol
Getting started with pySerial
Installing pySerial
Playing with a pySerial example
Bridging pySerial and Firmata
Summary
3. The First Project – Motion-triggered LEDs
Motion-triggered LEDs – the project description
The project goal
The list of components
The software flow design
The hardware system design
Introducing Fritzing – a hardware prototyping software
Working with the breadboard
Designing the hardware prototype
Testing hardware connections
Method 1 – using a standalone Arduino sketch
The project setup
The Arduino sketch
The setup() function
The loop() function
Working with custom Arduino functions
Testing
Troubleshooting
Method 2 – using Python and Firmata
The project setup
Working with Python executable files
The Python code
Working with pyFirmata methods
Working with Python functions
Testing
Troubleshooting
Summary
4. Diving into Python-Arduino Prototyping
Prototyping
Working with pyFirmata methods
Setting up the Arduino board
Configuring Arduino pins
The direct method
Assigning pin modes
Working with pins
Reporting data
Manual operations
The write() method
The read() method
Additional functions
Upcoming functions
Prototyping templates using Firmata
Potentiometer – continuous observation from an analog input
Connections
The Python code
Buzzer – generating sound alarm pattern
Connections
The Python code
DC motor – controlling motor speed using PWM
Connections
The Python code
LED – controlling LED brightness using PWM
Connections
The Python code
Servomotor – moving the motor to a certain angle
Connections
The Python code
Prototyping with the I2C protocol
Arduino examples for I2C interfacing
Arduino coding for the TMP102 temperature sensor
Arduino coding for the BH1750 light sensor
PyMata for quick I2C prototyping
Interfacing TMP102 using PyMata
Interfacing BH1750 using PyMata
Useful pySerial commands
Connecting with the serial port
Reading a line from the port
Flushing the port to avoid buffer overflow
Closing the port
Summary
5. Working with the Python GUI
Learning Tkinter for GUI design
Your first Python GUI program
The root widget Tk() and the top-level methods
The Label() widget
The Pack geometry manager
The Button() widget – interfacing GUI with Arduino and LEDs
The Entry() widget – providing manual user inputs
The Scale() widget – adjusting the brightness of an LED
The Grid geometry manager
The Checkbutton() widget – selecting LEDs
The Label() widget – monitoring I/O pins
Remaking your first Python-Arduino project with a GUI
Summary
6. Storing and Plotting Arduino Data
Working with files in Python
The open() method
The write() method
The close() method
The read() method
The with statement – Python context manager
Using CSV files to store data
Storing Arduino data in a CSV file
Getting started with matplotlib
Configuring matplotlib on Windows
Configuring matplotlib on Mac OS X
Upgrading matplotlib
Troubleshooting installation errors
Setting up matplotlib on Ubuntu
Plotting random numbers using matplotlib
Plotting data from a CSV file
Plotting real-time Arduino data
Integrating plots in the Tkinter window
Summary
7. The Midterm Project – a Portable DIY Thermostat
Thermostat – the project description
Project background
Project goals and stages
The list of required components
Hardware design
Software flow for user experience design
Stage 1 – prototyping the thermostat
The Arduino sketch for the thermostat
Interfacing the temperature sensor
Interfacing the humidity sensor
Interfacing the light sensor
Using Arduino interrupts
Designing the GUI and plot in Python
Using pySerial to stream sensor data in your Python program
Designing the GUI using Tkinter
Plotting percentage humidity using matplotlib
Using button interrupts to control the parameters
Changing the temperature unit by pressing a button
Swapping between the GUI and the plot by pressing a button
Troubleshooting
Stage 2 – using a Raspberry Pi for the deployable thermostat
What is a Raspberry Pi?
Installing the operating system and configuring the Raspberry Pi
What do you need to begin using the Raspberry Pi?
Preparing an SD card
The Raspberry Pi setup process
Using a portable TFT LCD display with the Raspberry Pi
Connecting the TFT LCD using GPIO
Configuring th...

Table des matiĂšres