Example: confidence

Learning Arduino with C Programming

Learning Arduino with C Programming Version Copyright c June 22, 2017 by UC Davis C-STEM Center, All rights reserved. 1. Contents 1 Introduction 6. The Board .. 7. The External Circuitry .. 8. The Breadboard .. 12. The Pins .. 13. Circuit Diagrams .. 15. 2 Getting Started with Programming the Arduino in Ch 16. Project 1: Blink .. 16. New Concepts .. 16. Required Components and Materials .. 16. Building the Circuit .. 17. Using the ChDuino GUI .. 20. Find and Manage Arduino Boards .. 20. Connect and Control an Arduino Board .. 21. ChDuino Basic Test .. 21. Using ChIDE to Run Programs .. 22. Writing the Code .. 24. Alternate Method Using the While-loop.

like reading information from a sensor or controlling a motor. This is unlike the microprocessor in a typical computer, which can run multiple programs at once and is used for general purposes. Microcontrollers are typically used for what are called embedded systems. Embedded systems are only programmed once for

Tags:

  Embedded, Microprocessor

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Learning Arduino with C Programming

1 Learning Arduino with C Programming Version Copyright c June 22, 2017 by UC Davis C-STEM Center, All rights reserved. 1. Contents 1 Introduction 6. The Board .. 7. The External Circuitry .. 8. The Breadboard .. 12. The Pins .. 13. Circuit Diagrams .. 15. 2 Getting Started with Programming the Arduino in Ch 16. Project 1: Blink .. 16. New Concepts .. 16. Required Components and Materials .. 16. Building the Circuit .. 17. Using the ChDuino GUI .. 20. Find and Manage Arduino Boards .. 20. Connect and Control an Arduino Board .. 21. ChDuino Basic Test .. 21. Using ChIDE to Run Programs .. 22. Writing the Code .. 24. Alternate Method Using the While-loop.

2 26. Exercises .. 28. 3 Function Definitions and Arduino 's Setup and Loop Functions 29. 4 Programming with the Arduino IDE 32. 5 Using Debug Mode to Understand and Troubleshoot Programs 35. 6 Interfacing with a Push-Button 44. Project 2: Spaceship Interface .. 44. New Concepts .. 44. Required Components and Materials .. 44. Building the Circuit .. 45. ChDuino Basic Test .. 47. Writing the Code .. 47. Exercises .. 51. 7 Reading an Analog Temperature Sensor 52. Project 3: Love-O-Meter .. 52. New Concepts .. 52. Required Components and Materials .. 52. Building the Circuit .. 53. ChDuino Basic Test .. 55. Writing the Code .. 55. Exercises.

3 61. 2. 8 Using a Potentiometer to Dim an LED 62. Project 4: Dimmer .. 62. New Concepts .. 62. Required Components and Materials .. 62. Building the Circuit .. 63. ChDuino Basic Test .. 65. Writing the Code .. 65. Exercises .. 67. 9 Using Photo-Resistors to Change the Brightness and Color of an RGB LED 68. Project 5: Color Mixing Lamp .. 68. New Concepts .. 68. Required Components and Materials .. 68. Building the Circuit .. 69. ChDuino Basic Test .. 71. Writing the Code .. 71. Exercises .. 75. 10 Turning a Servo Motor with a Potentiometer 76. Project 6: Mood Cue .. 76. New Concepts .. 76. Required Components and Materials .. 76. Building the Circuit.

4 77. ChDuino Basic Test .. 80. Writing the Code .. 80. Exercises .. 83. 11 Playing Notes with a Piezo and Photo-resistor 84. Project 7: Light Theremin .. 84. New Concepts .. 84. Required Components and Materials .. 84. Building the Circuit .. 85. ChDuino Basic Test .. 87. Writing the Code .. 87. Exercises .. 90. 12 Pressing Different Buttons to Play Different Notes on a Piezo 91. Project 8: Keyboard Instrument .. 91. New Concepts .. 91. Required Components and Materials .. 91. Building the Circuit .. 92. ChDuino Basic Test .. 96. Writing the Code .. 96. Exercises .. 99. 13 Data Acquisition and Plotting Using a Photo-resistor 100. Project 9: Graphing Light.

5 100. New Concepts .. 100. Required Components and Materials .. 100. Building the Circuit .. 101. Writing the Code .. 102. Exercises .. 107. 3. 14 Data Acquisition and Plotting with Multiple Inputs and Outputs Using a Photo-resistor and a Potentiometer 108. Project 10: 3D Graphing .. 108. New Concepts .. 108. Required Components and Materials .. 108. Building the Circuit .. 109. Writing the Code .. 111. Exercises .. 117. 15 Using Data Acquisition to Verify Ohm's Law 118. Project 11: Science! .. 118. New Concepts .. 118. Required Components and Materials .. 118. Building the Circuit .. 119. Writing the Code .. 120. Exercises .. 126. 16 Timing a Program 127.

6 Project 12: Digital Hourglass .. 127. New Concepts .. 127. Required Components and Materials .. 127. Building the Circuit .. 128. Writing the Code .. 131. Exercises .. 135. 17 Moving a DC Motor by Pressing a Button 136. Project 13: Motorized Pinwheel .. 136. New Concepts .. 136. Required Components and Materials .. 136. Building the Circuit .. 137. ChDuino Basic Test .. 141. Writing the Code .. 141. Exercises .. 143. 18 Controlling the Speed and Direction of a DC Motor 144. Project 14: Zoetrope .. 144. New Concepts .. 144. Required Components and Materials .. 144. Building the Circuit .. 145. ChDuino Basic Test .. 149. Writing the Code.

7 149. Exercises .. 154. 19 Writing on an LCD Panel 155. Project 15: Crystal Ball .. 155. New Concepts .. 155. Required Components and Materials .. 155. Building the Circuit .. 156. Writing the Code .. 160. Exercises .. 165. 4. 20 Using a Piezo as a Vibration Sensor 166. Project 16: Knock Lock .. 166. New Concepts .. 166. Required Components and Materials .. 166. Building the Circuit .. 167. ChDuino Basic Test .. 170. Writing the Code .. 170. Exercises .. 177. 21 Appendix 178. Differences Between Learning Arduino in Ch for the Absolute Beginner and Learning Arduino in C .. 178. Resistor Color Codes .. 179. Using the Multi-Meter .. 180.

8 Current .. 180. Voltage .. 180. Resistance .. 181. Macros .. 182. Functions in Ch .. 183. Functions in Ch and Arduino IDE .. 183. Classes .. 187. The Serial Class in Ch and Arduino IDE .. 187. The Servo Class in Ch and Arduino IDE .. 188. The LiquidCrystal Class in Ch and Arduino IDE .. 188. The CPlot Class in Ch .. 190. Input/Output Alternatives .. 191. Installing Arduino Firmware For Ch .. 192. 5. 1 Introduction For engineers, artists, and students alike, the Arduino single-board microcontroller is one of the most popular of its kind in the world. The rise of the Arduino , and similar boards, has brought the diverse functionality and power of microcontrollers into the realm of the everyday person by not only displaying near unlimited usefulness in household tasks, but also by bringing to light the fun and creative side to engineering.

9 This document will be a walk-through in how to program a microcontroller to interact with electronic components using ChIDE and the Ch Programming language. Ch and ChIDE provide the ability to enter a line-by-line debugging mode which can be invaluable to the absolute beginner programmer and breed a greater intuition about how a program actually works. As an interpreter, ChIDE also does not need to be re-uploaded to the Arduino after every change in the code, unlike with the Arduino IDE, meaning that Ch has a faster transition time between the editing and the execution of code, keeping students engaged and giving them more time in a classroom setting to troubleshoot or experiment.

10 The Ch code is written in such a way that it is nearly identical to the what the Arduino code would be such that the code from a Ch program can be copied and paste into the Arduino Programming environment and function the same way, creating a smooth transition from ChIDE to the Arduino IDE. This gives students easy experience with different Programming environments and the dynamic nature of Programming and Programming languages. This book assumes that the user has the hardware from the C-STEM Starter Kit and C-STEM Sensor Kit. These kits are available for purchase from C-STEM. Industrial Partners. These projects and lessons provide a basic knowledge of how microcontrollers function with inputs (such as switches, knobs, temperature and light sensors) and outputs (such as LEDs, servos, motors).


Related search queries