Date post: | 13-Dec-2015 |
Category: |
Documents |
Upload: | kelley-banks |
View: | 214 times |
Download: | 2 times |
2
What is smart design?• Everything is designed except
nature• The packaging of a Band-Aid• The curve of a bike frame• The shape of a city street light
• Smart designs include a microprocessor (i.e. – a small computer)
• Logic gives the design “intelligence”
• Code is the language used
3
Arduino• Arduino’s are the baby of the
desktop/laptop era• Small portable computer
(microprocessor + inputs/outputs)• Programmed using Arduino Integrated
Development Environment (IDE)• Inputs (instead of mouse and keyboard)
• Buttons, flex sensors, etc.• Outputs (instead of monitor and speakers)
• Motors, LEDs, etc.
4
SparkFun Inventor Kit• SparkFun Inventor Kit (SIK)
compiles many components to interface with the Arduino
• Inputs produce voltages to be read by the Arduino
• Outputs are controlled using voltages produced by the Arduino
• Smart Design teaching tool!
5
Computer CodeLanguage Code Examples Description
Nouns VariablesIntegers (int)
Booleans (boolean)Letters (char)
Variables hold data of certain types like numbers/arrays/letters
Verbs StructuresIf, else, endFor…end
While…end
Structures cause action. They can create loops, create switches, or define cases.
AdjectivesComparison Operators
Equal to (==)Less than (<)
Greater than (<)
Comparison operators describe variables in order to make logic based decisions
AdverbsArithmetic Operators
Addition (+)Multiplication (*)
Division (/)
Arithmetic operators describe the action occurring between two variables
Punctuation SyntaxSemicolons (;)Brackets ({})
Parentheses ()
Syntax groups and separates code in discernible segments.
6
Variables• Variable = Noun
• Variables are the subject of the code (person/place/thing)
• Variables are distinguished by type• Integers - int are whole numbers between [-
32768,32768]• Boolean – boolean are either a true (1) or false (0)• Letters – char are alphabet letters between [A-Z]• Any many more – see Reference
8
Structures• Structures = Verbs
• Give the code motion/action• Structures provide various actions
• For loops – repeats statements within loop for a certain number of times
• If/else statements –tests to see if an equation is satisfied, then directs code to appropriate statements
• While loops – repeat statements within loop until condition is met
9
Structures
1. What is a for loop that you notice in your daily life?
2. What is an if/else statement that you notice in your daily life?
QUIZ!
10
Structures
1. What is a for loop that you notice in your daily life?- Microwave 30second timer- Traffic lights turning green, then yellow, then red
2. What is an if/else statement that you notice in your daily life?
- Alarm clock turning on at 6:26am- Street lights turning on at night
Examples?
Comparison Operators
11
• Comparison Operators = adjectives• Describe variables by comparing to other values
• Comparison operators are mathematical inequality terms and return a boolean variable
• Equal to (==) – asks if two values are equal• Not equal to (!=) – asks if two values are not equal• Less/Greater than (< / >) – asks if one variable is
less/greater than another• Any many more – see Reference
12
Arithmetic Operators• Arithmetic Operators = adverbs
• Describe the action occurring between two variables• Arithmetic operators are mathematical operators between
numeric variables• Addition (+) – you know what this means…• Multiplication (*) – you know what this means…• Division (/) – you know what this means…• Any many more – see Reference
13
Syntax• Syntax = punctuation
• Groups and separates code in discernible segments• Syntax is required by computers in order to decipher the
meaning of each line of code• Semicolons (;) – ends a statement and will prevent
complier errors• Curly Braces ({}) – defines begin/end of various
structures including for loops, if/else statements, and functions
• Parentheses () – many uses including defining order of operation in an equation, indicating arguments for a function, etc.
• Any many more – see Reference
14
Functions• Functions = paragraphs
• Short sequence of code with specific purpose/action• Functions provide another method to organize code into
discernible sections. Allows for easy reuse of code• Commonly used functions
• digitalWrite() – write a HIGH or a LOW value to a digital pin (i.e. – output a voltage of 5V or 0V)
• analogRead() – read an analog signal and digitize using 10-bit analog to digital converter (i.e. – map input voltages [0-5V] to integers [0-1023]
• delay() – pauses the program for the specified amount of time
• Any many more – see Reference. Lots!!