QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

13
QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI

Transcript of QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

Page 1: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

QSETELECTRICAL TEAM

ARDUINO TUTORIAL I

BY: JOSHUA ARDUINI

Page 2: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

WHAT IS ARDUINO

• Microcontroller

• Allows for quick prototyping of ideas

• Accepts both digital and analog signals

• Simple to use

• Readily available online support / help / documentation

• Big part of the QSET Rover

Page 3: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

DOWNLOADING ARDUINO IDE1. Go to WWW.ARDUINO.CC2. Select “Download”3. Download the appropriate version

& follow instructions

Page 4: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

GETTING STARTED

• Ensure Arduino.exe will open

• Navigate to www.123d.circuits.io

• Create an account

• Then select “New Breadboard Circuit”

Page 5: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

THE BREADBOARD

• Two sections

• Connected horizontally labelled by + and – • Each row is a separate piece of wire

• Connected vertically labeled 1 – 60 in this case but can have more or less

• Each column is a separate piece of wire

• Pattern repeats after the dotted line. This gap separates the electrical connections.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Page 6: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

BASIC L.E.D. CIRCUIT

The arrow marks the direction of current flow.

Voltage supply comes directly from the Arduino board (in this example)

V = 5 VR = 330 Ω

Page 7: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

CREATING THE CIRCUIT ON 123D.CIRCUITS

DEMO

Page 8: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

WRITING THE ARDUINO CODE

Typically in 3 main parts

1. Initialization of variables

2. Setting up the hardware to recognize components

3. Loop instance that runs indefinitely

Page 9: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

1. INITIALIZATION OF VARIABLES

• In this case we only need one variable

• “int” denotes that it is an integer

• led was the chosen name for the variable

• 13 is the pin we are plugging the LED into

Page 10: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

2. SETTING UP THE HARDWARE TO RECOGNIZE COMPONENTS• “Void setup() “ tells the

compiler we are going to start our setup phase of code

• “pinMode” tells the compiler that we need to do a pin assignment. This instruction has the form: pinMode(PIN#,mode);

• PIN# - Taken from the #s on the board

• Mode – Tell the compiler if it is going to be an INPUT or an OUTPUT.

• “” denotes the end of the setup function

Page 11: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

3. LOOP INSTANCE THAT RUNS INDEFINITELY• “Void loop() “ tells the compiler we are

going to start our loop phase of code

• “digitalWrite” tells the compiler that we would like to set a digital value. 1(current) OR 0(no current).

• This instruction is of the form digitalWrite(PIN#, Value).

• PIN# - The pin we want to alter

• Value – Whether we want it to be a HIGH(1) or LOW(0)

• “delay” tells the compiler to wait for a duration of 1000ms (1 second).

Page 12: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

3. LOOP INSTANCE THAT RUNS INDEFINITELY CONT.

• Now we do the “digitalWrite” to tell the LED to turn off and wait 1000ms

• “” tells the compiler that this is the end of the instructions that we want to loop

• Once the program has executed the second delay, it will go up to the beginning of the loop and turn the LED on again

Page 13: QSET ELECTRICAL TEAM ARDUINO TUTORIAL I BY: JOSHUA ARDUINI.

NOW EXECUTE ON 123D.CIRUITS

DEMO