Beginning c for arduino learn c programming for the arduino.pdf

(28168 KB) Pobierz
Technology in AcTion
Beginning C
for Arduino
Learn C Programming for the Arduino
and Compatible Microcontrollers
Take complete control of your Arduino
with the power of C
Ph.D. Jack Purdum
1061955808.040.png 1061955808.049.png 1061955808.050.png 1061955808.051.png 1061955808.001.png 1061955808.002.png
 
 
 
1061955808.003.png
 
 
 
 
 
 
1061955808.004.png 1061955808.005.png 1061955808.006.png 1061955808.007.png 1061955808.008.png 1061955808.009.png 1061955808.010.png 1061955808.011.png 1061955808.012.png 1061955808.013.png 1061955808.014.png 1061955808.015.png 1061955808.016.png 1061955808.017.png 1061955808.018.png 1061955808.019.png 1061955808.020.png 1061955808.021.png 1061955808.022.png 1061955808.023.png 1061955808.024.png 1061955808.025.png 1061955808.026.png 1061955808.027.png 1061955808.028.png 1061955808.029.png 1061955808.030.png 1061955808.031.png 1061955808.032.png 1061955808.033.png 1061955808.034.png 1061955808.035.png 1061955808.036.png 1061955808.037.png 1061955808.038.png 1061955808.039.png 1061955808.041.png 1061955808.042.png 1061955808.043.png
 
Beginning C for Arduino
n n n
Jack Purdum
1061955808.044.png
Beginning C for Arduino
Copyright © 2012 by Jack Purdum
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-4302-4776-0
ISBN-13 (electronic): 978-1-4302-4777-7
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the beneit of the trademark owner, with no intention of infringement of the
trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even
if they are not identiied as such, is not to be taken as an expression of opinion as to whether or not they
are subject to proprietary rights.
President and Publisher: Paul Manning
Lead Editor: Michelle Lowman
Developmental Editor: Matthew Moodie
Technical Reviewer: Brad Levy
Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Louise Corrigan, Morgan
Ertel, Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham,
Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic
Shakeshaft, Gwenan Spearing, Matt Wade, Tom Welsh
Coordinating Editor: Katie Sullivan
Copy Editor: Mary Behr
Compositor: Bytheway Publishing Services
Indexer: SPi Global
Artist: SPi Global
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th
Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.
com , or visit www.springeronline.com .
For information on translations, please e-mail rights@apress.com , or visit www.apress.com .
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our Special
Bulk Sales–eBook Licensing web page at http://www.apress.com/bulk-sales .
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any
liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly
or indirectly by the information contained in this work.
Any source code or other supplementary materials referenced by the author in this text is available to
readers at www.apress.com . For detailed information about how to locate your book’s source code, go to
http://www.apress.com/source-code/ .
ii
To Jane for her unwavering support during this project.
iii
Contents at a Glance
About the Author ................................................................................................................ xiii
About the Technical Reviewer ............................................................................................ xiv
Acknowledgments ............................................................................................................... xv
Introduction ........................................................................................................................ xvi
Chapter 1: Introduction ......................................................................................................... 1
Chapter 2: Arduino C ........................................................................................................... 21
Chapter 3: Arduino C Data Types ........................................................................................ 37
Chapter 4: Decision Making in C ......................................................................................... 55
Chapter 5: Program Loops in C ........................................................................................... 77
Chapter 6: Functions in C .................................................................................................... 91
Chapter 7: Storage Classes and Scope ............................................................................. 113
Chapter 8: Introduction to Pointers .................................................................................. 131
Chapter 9: Using Pointers Effectively ............................................................................... 151
Chapter 10: Structures, Unions, and Data Storage ........................................................... 171
Chapter 11: The C Preprocessor and Bitwise Operations ................................................ 197
Chapter 12: Arduino Libraries ........................................................................................... 211
Appendix A: Suppliers and Sources.................................................................................. 231
Appendix B: Electronic Components for Experiments ..................................................... 237
Answers to Exercises ........................................................................................................ 241
Index .................................................................................................................................. 257
iv
1061955808.045.png 1061955808.046.png 1061955808.047.png 1061955808.048.png
 
Zgłoś jeśli naruszono regulamin