Getting Started with .NET Gadgeteer Simon Monk docx

87 1.5K 0
Getting Started with .NET Gadgeteer Simon Monk docx

Đ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

www.it-ebooks.info www.it-ebooks.info Getting Started with .NET Gadgeteer Simon Monk Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo www.it-ebooks.info Getting Started with .NET Gadgeteer by Simon Monk Copyright © 2012 O’Reilly Media. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more informa- tion, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Editor: Rachel Roumeliotis Production Editor: Melanie Yarbrough Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Rebecca Demarest May 2012: First Edition. Revision History for the First Edition: May 04, 2012 First release See http://oreilly.com/catalog/errata.csp?isbn=9781449328238 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Getting Started with .NET Gadgeteer, the cover image of a web messenger, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 978-1-449-32823-8 [LSI] 1336404032 www.it-ebooks.info Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v 1/Getting Started with .NET Gadgeteer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 What Is .NET Gadgeteer? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 The Fez Starter Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Powering Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Mac and Linux Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 Install Visual Studio Express . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Install .NET Micro Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Install the .NET Gadgeteer Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Upgrading the Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 Creating a New Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 Adding Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Trying It for Real . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 2/Spy Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 The Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 The Camera Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Trying It Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 WPFWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 Creating a UI Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Showing Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 The Final Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Touch Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Writing to SD cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 3/Snowflakes Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 The Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Using the Joystick module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 Contents iii www.it-ebooks.info 4/Web Messenger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Web Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 A Gadgeteer Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 A Gadgeteer Sketch Pad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Sharing with the World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 5/Camera Backup Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 The Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 The USB Host Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 The Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Copying Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 6/What Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Other Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Environmental Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71 Pulse Oximeter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Cellular Radio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 Relay Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 WiFi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Physical Design Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Blogs and Web Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 iv Contents www.it-ebooks.info Preface Introduction .NET Gadgeteer is a wonderful system for constructing prototypes of elec- tronic gadgets. It is supported by a range of modules that are connected to a Mainboard with plug-in cables. This book will lead you through the process of installing the necessary soft- ware onto your computer and then take you through a series of exciting projects that will give you the confidence and skill to start designing your own gadgets. What You Will Need The book restricts itself to using components from the Fez Starter Kit de- veloped by GHI Electronics. This particular kit is probably the most popular starter kit and is available from a range of vendors on the Internet, including GHI themselves (http:// www.ghielectronics.com). All the programs for the projects can be downloaded from the book’s website at http://www.gadgeteerbook.com. How to Use this Book You need to read Chapter 1 to get you started, but then you can pick and choose from the remaining project chapters. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. www.it-ebooks.info Constant width Used for program listings, as well as within paragraphs to refer to pro- gram elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold Shows commands or other text that should be typed literally by the user. Constant width italic Shows text that should be replaced with user-supplied values or by val- ues determined by context. TIP: This icon signifies a tip, suggestion, or general note. CAUTION: This icon indicates a warning or caution. Using Code Examples This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require per- mission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Getting Started with .NET Gadgeteer by Simon Monk (O’Reilly). Copyright 2012 O’Reilly Me- dia, Inc., 978-1-449-32823-8.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com. vi Preface www.it-ebooks.info Safari® Books Online Safari Books Online (www.safaribooksonline.com) is an on-de- mand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business. Technology professionals, software developers, web designers, and busi- ness and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training. Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manu- scripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Tech- nology, and dozens more. For more information about Safari Books Online, please visit us online. How to Contact Us You can write to us at: Maker Media 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada) 707-829-0515 (international or local) 707-829-0104 (fax) Maker Media is a division of O’Reilly Media devoted entirely to the growing community of resourceful people who believe that if you can imagine it, you can make it. Consisting of Make magazine, Craft magazine, Maker Faire, as well as the Hacks, Make:Projects, and DIY Science book series, Maker Media encourages the Do-It-Yourself mentality by providing creative inspiration and instruction. For more information about Maker Media, visit us online: MAKE: www.makezine.com CRAFT: www.craftzine.com Maker Faire: www.makerfaire.com Hacks: www.hackszine.com Preface vii www.it-ebooks.info We have a web page for this book, where we list examples, errata, and plans for future editions. You can find this page at http://oreil.ly/getstarted_dot netgadgeteer. To comment on the book, send email to bookquestions@oreilly.com. For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com. Find us on Facebook: http://facebook.com/oreilly Follow us on Twitter: http://twitter.com/oreillymedia Watch us on YouTube: http://www.youtube.com/oreillymedia Acknowledgements I thank Linda for giving me the time, space, and support to write this book and for putting up with the various messes my projects create around the house. Thanks to Patrick Olivier, Tom Bartindale, Thomas Smith and Jonathan Hook from Culture Lab, for their excellent feedback and help. Many thanks to the technical reviewers, Scott Gowell and William Wallace. Finally, I would like to thank Rachel Roumeliotis, Brian Jepson and everyone an O’Reilly who has had a hand in producing this book. viii Preface www.it-ebooks.info [...]...1 /Getting Started with NET Gadgeteer If you like making things, then you will love NET Gadgeteer You can create many interesting projects by just plugging together components and writing a few lines of programming code What Is NET Gadgeteer? The NET Gadgeteer system is developed by Microsoft to allow people to build small electronic projects The modules that are available all conform to the NET Gadgeteer. .. desktop, by clicking Extract All Files (see Figure 1-8) 8 Getting Started with NET Gadgeteer www.it-ebooks.info Figure 1-7 Visual Studio C# Express Installer Download and Install Figure 1-8 NET Micro Framework Installation Inside the extracted folder, open the file MicroFrameworkSDK, which will run the installer (see Figure 1-9) Getting Started with NET Gadgeteer www.it-ebooks.info 9 Figure 1-9 NET Micro... click Update Getting Started with NET Gadgeteer www.it-ebooks.info 11 Figure 1-11 Upgrading the Firmware—Selecting the Mainboard Follow the instructions in Figure 1-12 Unless you changed the installation location when you were running the installer, you can accept the default locations for the files Click Step 2 Figure 1-12 Upgrading the Firmware—File Locations 12 Getting Started with NET Gadgeteer www.it-ebooks.info... instructions are for VirtualBox, but they will be similar for other virtualization software You will also need to allow the USB connection to the Gadgeteer to pass through to the virtual machine without OS X or Linux interfering with it To Getting Started with NET Gadgeteer www.it-ebooks.info 5 do this, select your virtual machine in the VirtualBox control window and click Settings Select Ports and then... will not only install the files you need for the Fez Spider from GHI but also the software needed for the NET Gadgeteer modules provided by the company SeeedStudio It will also install the USB drivers required by the hardware 10 Getting Started with NET Gadgeteer www.it-ebooks.info Figure 1-10 NET Gadgeteer Installer Accept all the defaults of the installers that will each be run automatically in turn... new programming language In the case of Gadgeteer, where we are concerned with hardware, we will make our first program turn an LED on and off when we press a button Start Visual Studio by launching the “Microsoft Visual C# 2010 Express” shortcut in your Start menu, which will be found inside All Programs→ Microsoft Visual C# 2010 Express Getting Started with NET Gadgeteer www.it-ebooks.info 13 Creating... want a Gadgeteer project by selecting the Gadgeteer option within Visual C# We also need to provide the project with a name, which is done at the bottom of the window We can just call the project “Hello” When you have done this, click OK, and Visual Studio will construct the basic framework of a new project for us When it has finished, Visual Studio will look something like Figure 1-15 14 Getting Started. .. project and give it the name “Spy Camera Test.” We have added “Test” to its name so as not to get it mixed up with the final Spy Camera 22 Getting Started with NET Gadgeteer www.it-ebooks.info Project If you are not sure how to make a new project, refer to “Creating a New Project” on page 14 As with our “Hello World” project in Chapter 1, the first step in this project is to add the necessary components... Mainboards (see Figure 1-4) For the time being, ignore any messages about drivers coming from your computer; we will come to that in the next section 4 Getting Started with NET Gadgeteer www.it-ebooks.info Figure 1-4 Mainboard Powered Up Installation To use Gadgeteer, we need a computer; it must be a computer that can run Windows XP, Vista, or 7 If you are a Mac or Linux user, then all is not lost if you... Joystick Module 2 axis joystick with press button Some parts, like the LCD Display, are easy to identify while some, like “the extender,” are less obvious If you look closely, they all have a label printed on them Most of the modules have a single connector on them that will be attached to a lead that then plugs into one of the connectors on the Getting Started with NET Gadgeteer www.it-ebooks.info 3 . www.it-ebooks.info www.it-ebooks.info Getting Started with .NET Gadgeteer Simon Monk Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo www.it-ebooks.info Getting Started with .NET Gadgeteer by. . . . . . . v 1 /Getting Started with .NET Gadgeteer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 What Is .NET Gadgeteer? . . .

Ngày đăng: 23/03/2014, 14:20

Từ khóa liên quan

Mục lục

  • Contents

  • Preface

    • Introduction

    • What You Will Need

    • How to Use this Book

    • Conventions Used in This Book

    • Using Code Examples

    • Safari® Books Online

    • How to Contact Us

    • Acknowledgements

    • Chapter 1. Getting Started with .NET Gadgeteer

      • What Is .NET Gadgeteer?

      • The Fez Starter Kit

      • Powering Up

      • Installation

        • Mac and Linux Users

        • Install Visual Studio Express

        • Install .NET Micro Framework

        • Install the .NET Gadgeteer Package

        • Upgrading the Firmware

        • Hello World

          • Creating a New Project

          • Adding Components

          • Trying It for Real

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

  • Đang cập nhật ...

Tài liệu liên quan