Book Image

Python Programming for Arduino

Book Image

Python Programming for Arduino

Overview of this book

Table of Contents (18 chapters)
Python Programming for Arduino
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Storing Arduino data in a CSV file


In the previous two sections, you learned methods to store values in a CSV file. Although the data required for the file was already initialized in the code, the same code could be modified to store Arduino input data.

To begin with storing Arduino data, let's create a circuit that produces these values for us. We used a motion sensor in the project of Chapter 3, The First Project – Motion-triggered LEDs, and a potentiometer in the exercise of Chapter 4, Diving into Python-Arduino Prototyping. We will be using these two sensors to provide us with digital and analog input values respectively. To develop the circuit required for this exercise, connect the potentiometer to the analog pin 0 and the PIR motion sensor to digital pin 11, as displayed in the following diagram:

Connect other Arduino pins such as 5V and the ground, as shown in the preceding Fritzing diagram. As we are going to use pyFirmata to interface Python with the Arduino board, you will have...