Introduction to the Arduino MicroController Tinkering Program Day

  • Slides: 20
Download presentation
Introduction to the Arduino Micro-Controller Tinkering Program Day #2

Introduction to the Arduino Micro-Controller Tinkering Program Day #2

What Is Arduino and Where Did It Come From? • Arduinos are great Italian

What Is Arduino and Where Did It Come From? • Arduinos are great Italian microcontrollers! • In 2005 the Arduino Project began in response to a need for affordable and easy-to-use devices. • The most recent main board to date is the Arduino Uno R 3 which was released in 2011. • Think of it as the plain-vanilla of Arduino boards: it’s a good and reliable workhorse.

BEFORE BREADBOARDS Before breadboards there was a technique called “Wire-Wrapping” where you’d wrap wires

BEFORE BREADBOARDS Before breadboards there was a technique called “Wire-Wrapping” where you’d wrap wires around conductive posts attached to a perfboard.

Long ago electronics were bulky and big so people would grab a breadboard and

Long ago electronics were bulky and big so people would grab a breadboard and start connecting wires onto the board to give themselves a platform to build their circuits

HOW BREADBOARDS WORK

HOW BREADBOARDS WORK

JUMPER WIRES Jumper Wires have connector pins at each end allowing for them to

JUMPER WIRES Jumper Wires have connector pins at each end allowing for them to be used to connect two points to each other without soldering. They come in lots of colors to differentiate types of connections.

The LED Fade Sketch • IMPORTANT: Always make sure that your circuit is not

The LED Fade Sketch • IMPORTANT: Always make sure that your circuit is not powered while you’re making changes to it. You can easily make incorrect connections that can potentially damage the components. • Long leg from the LED connected to the resistor and GND wire. ,

Before You Begin Programming Always make sure to find the identify the appropriate board

Before You Begin Programming Always make sure to find the identify the appropriate board and serial device for your Arduino. To do so go up to: Tools Board To select the serial device for the board: Tools Port

Code File FACT: Arduino uses the programming language C, which is one of the

Code File FACT: Arduino uses the programming language C, which is one of the most widely used languages of all time! Examples Basics Fade To compile your code: Sketch Upload (or command-U) -ORSelect the Upload button

Understanding the Code When looking at the sketch as a whole you can identify

Understanding the Code When looking at the sketch as a whole you can identify four distinct sections: • Comments • Declarations • Void setup • Void loop

Understanding the Code: COMMENTS The //comments at the top of the sketch reveal exactly

Understanding the Code: COMMENTS The //comments at the top of the sketch reveal exactly what’s happening in this sketch. Code etiquette. You can also “comment out” multiple lines of code like this: /*comments more code Comments are completely ignored by the software more code when the sketch is compiled and uploaded. Comments */ can contain useful information about the code without interfering with how the code runs.

Understanding the Code: DECLARATIONS Declarations are values that are stored for later use by

Understanding the Code: DECLARATIONS Declarations are values that are stored for later use by the program and are usually declared before the setup. • In this case three VARIABLES are being declared. Variables are values that can change depending on what the program, does with them. • When declaring a variable it goes as type, name, and value. Type: int (integer: whole number), name, = integer value ;

Understanding the Code: FUNCTIONS • The next two sections are functions that begin with

Understanding the Code: FUNCTIONS • The next two sections are functions that begin with void. A function is a bit of code that performs a specific task. runs only once and assigns values and properties that do not change. • allows for the code to repeat a task without you having to write the code out again and again. • void setup and void loop must be included in every Arduino sketch in order for it to compile. They are “core functions” and you can tell by capitalizing a letter or adding another. The color of the functions with blacken. • • Functions are written in camel. Case.

Understanding the Loop Change your delay time!

Understanding the Loop Change your delay time!

The Button Sketch We are adding an additional LED: long leg in PIN 13

The Button Sketch We are adding an additional LED: long leg in PIN 13 and short leg in GND

Code • File Examples Digital • Command-U to upload Button

Code • File Examples Digital • Command-U to upload Button

Understanding the Code

Understanding the Code

Understanding the Code: Con’t Change if (button. State == LOW) {

Understanding the Code: Con’t Change if (button. State == LOW) {

You’ve officially completed 2 Arduino sketches!!

You’ve officially completed 2 Arduino sketches!!

NEXT WEEK

NEXT WEEK