ASK THE CAT
  • Ask
  • FAQ
  • Summer 2020 Tutoring
    • :: REPRESENT IT!
    • Pre-Algebra Sessions >
      • :: Basic Division
      • :: Complex Division
      • :: Estimation Division
      • :: Division Practice Problems
    • Algebra II >
      • :: Cubic Equations
      • :: Complex Numbers
    • Chemistry >
      • Molarity Basics
    • C++ Sessions >
      • :: Introduction
      • :: Style v Syntax
      • :: Variables & Data Types
      • :: Intialize/Declare Variables
      • :: Types of Operators
      • :: Strings and Input - Output
      • :: How to Construct Arrays
  • AP Bio
    • :: Sketch Notes >
      • :: Part 1
      • :: Part 2
    • :: Chi-Squared Tests
    • :: Cancer
    • :: Hox Genes
    • :: Hardy-Weinberg Principle
    • :: Rule of Multiplication + Addition for Punnett Squares
    • :: CRISPR
    • :: Amino Acid
    • :: Peptide
    • :: Why study Peptides
    • :: Aquaporins
    • :: Gram Stains
    • :: Graph on Excel for Bio Lab
  • AP Chem
    • Organic Chemistry
    • I. Properties of Matter >
      • Neutralization
    • II. Periodic table >
      • Org of Periodic Table
      • :: Groups
    • III. Chemical bonding >
      • :: Mass to Mass conversion
      • :: Naming Acids
      • :: Cross Drop Charge
      • :: Predicting Products
      • :: Balance Equation Question
      • :: Learn to Balance Equation
      • :: VSEPR Simulation
    • IV. Molar Mass >
      • ::LR ER and excess reatant
      • :: Molecular/Formula Mass
      • :: Empirical Formula & Molar Mass
      • :: Percentages & Empirical Formula
      • :: Empirical formula
    • IV. Solutions and Solubility >
      • :: Types of Solutions with Solubility Curves
      • :: Solubility Curve
    • V. Easy Tricks and Tips >
      • :: Tip to Molecular Shapes
      • Memorizing Bond Angles and Polarity
      • :: Chemistry Formulas
      • :: Trick Polyatomic ions
    • VI. General AP Concepts >
      • :: Potential Energy Diagrams
      • :: Haber-Bosch
      • :: Le Chatelier
      • :: Pressure & Moles
      • ::Rydberg's Constant vs Unit of Energy
      • :: Equilibrium and RICE Tables
      • :: Kinetics
      • Galvanic Cells
    • :: Flash cards
    • :: VSEPR
  • AP Stats
    • Chi-Squared Tests
    • Applications of Statistics
    • Standardized Scores
    • Distributions Transformations
  • AP Calc
    • DI Method - Tabular Integration
    • Polar Curves: Tangent Line and Slope
    • Riemann Sums: Left and Right Approximations
    • :: Conic Sections Flash cards
    • :: Parent Functions Flash cards
    • Worked Out Problems >
      • :: Worked Out Problems I
      • :: Worked Out Problems II
      • :: Worked Out Problems III
      • :: Worked Out Problems IV
      • :: Worked Out Problems V
      • :: Worked Out Problems VI
      • :: Worked Out Problems VII
      • :: Worked Out Problems VIII
      • :: Worked Out Problems IX
      • :: Worked Out Problems X
      • :: Worked Out Problems XI
      • :: Worked Out Problems XII
      • :: Worked Out Problems XIII
    • Applying Trig Identities
    • L'Hopital's Rule
    • Differences Between Conic Sections
    • Graphing Conic Sections
    • :: Pre-Calc - Trig Identities
    • Tangent & Normal Lines
    • Indefinite integrals: U Sub
    • Calculus Derivatives >
      • Product Rule
      • Quotient Rule
      • Chain Rule
  • AP CS A
    • Studying for AP CSA 2020
    • :: Control Structures
    • :: What is Networking
    • :: Recursion
    • :: While Do While Loops in Java
    • :: Interface in Java
    • :: ArrayLists
    • :: Java Naming Conventions
    • :: Logic Circuits
    • :: Getters and Setters
    • :: Binary & Hexadecimal
  • AP Español
    • AP Español Salsa
  • Arduino
    • Quick Look
    • Project #1: Blinking LED
    • Project #2: Button LED
    • Project #3: Flowing LED
    • Project #4: LCD Display
    • Project #5: Serial Monitor
  • App
    • AP Go Pow How?
    • AP Go Pow APP Page
  • Musings
    • :: Backward induction
    • :: what is ISS
    • :: Rotational Matrices
    • :: Primary v Secondary Pollutants
    • :: Black Hole
    • :: Covid-19 Hackathon
    • :: Evolution of Immunizations
    • :: Predictions of Diseases
    • :: Book List
    • :: Patterncount
    • :: Binary Classification
    • :: Cybersecurity
    • :: Self Similarity
    • :: Trig Identities
    • :: UIL Number S
    • :: Box Offensive Play
    • :: Why Card Trick Works
    • :: Easy Multiplication
  • AP CREDIT
  • About

Project #2: How to use a button with LED


Hook up 5 volts to one side of a button and to the other side of the button we connect pin 2. When you press the button it completes an electrical connection, pin 2 will “see” the 5 volts and if we digitalRead() at pin 2, it will report HIGH. During the times the button is not being pressed, pin 2 reports LOW.To turn on an LED by pressing the button, we simply make an if statement whose condition says something like “…if the voltage at pin 2 is HIGH, turn on the LED at pin 13…” It is really that easy.
Picture
We also have pin 2 connected to ground at all times through a resistor. This is because when we read values at pin 2, we want to get either a HIGH or a LOW reported. If pin 2 is not connected to ground, then when the button is not being pressed it becomes what is called a floating pin ( it’s not connected to anything). Floating pins on the Arduino are fine for the most part, unless you are trying to record an input from them, then they are bad, and can give you spurious information.
Step-by-Step Instructions:

  1. Connect one of the Arduino GND pins to one of the long power rails on the breadboard – this will be the ground rail.
  2. Connect the short leg of the LED to this same ground rail on the breadboard then connect the long leg to a row on the breadboard.
  3. Connect the 220-ohm resistor from pin 13 to the same row that you have the long leg of the LED attached.
  4. Place the pushbutton on the breadboard. Most buttons will straddle the center trench on the breadboard.
  5. Connect a jumper wire from the 5-volt pin to one side of the pushbutton.
  6. Connect a jumper wire from pin 2 to the other side of the pushbutton.
  7. Connect one side of the 10k resistor from the ground rail on the breadboard to the other side to the pushbutton – on the same side that pin 2 connects.
  8. Plug the Arduino board into your computer with a USB cable.
  9. Open the Arduino IDE.
  10. Open the sketch for this section.
  11. Click the Verify button on the top left. It should turn orange and then back to blue.
  12. Click the Upload button. It will also turn orange and then blue once the sketch has finished uploading to your Arduino board.
  13. Press the button a couple times and see how the LED at pin 13 reacts.

Picture

keentween

  • Ask
  • FAQ
  • Summer 2020 Tutoring
    • :: REPRESENT IT!
    • Pre-Algebra Sessions >
      • :: Basic Division
      • :: Complex Division
      • :: Estimation Division
      • :: Division Practice Problems
    • Algebra II >
      • :: Cubic Equations
      • :: Complex Numbers
    • Chemistry >
      • Molarity Basics
    • C++ Sessions >
      • :: Introduction
      • :: Style v Syntax
      • :: Variables & Data Types
      • :: Intialize/Declare Variables
      • :: Types of Operators
      • :: Strings and Input - Output
      • :: How to Construct Arrays
  • AP Bio
    • :: Sketch Notes >
      • :: Part 1
      • :: Part 2
    • :: Chi-Squared Tests
    • :: Cancer
    • :: Hox Genes
    • :: Hardy-Weinberg Principle
    • :: Rule of Multiplication + Addition for Punnett Squares
    • :: CRISPR
    • :: Amino Acid
    • :: Peptide
    • :: Why study Peptides
    • :: Aquaporins
    • :: Gram Stains
    • :: Graph on Excel for Bio Lab
  • AP Chem
    • Organic Chemistry
    • I. Properties of Matter >
      • Neutralization
    • II. Periodic table >
      • Org of Periodic Table
      • :: Groups
    • III. Chemical bonding >
      • :: Mass to Mass conversion
      • :: Naming Acids
      • :: Cross Drop Charge
      • :: Predicting Products
      • :: Balance Equation Question
      • :: Learn to Balance Equation
      • :: VSEPR Simulation
    • IV. Molar Mass >
      • ::LR ER and excess reatant
      • :: Molecular/Formula Mass
      • :: Empirical Formula & Molar Mass
      • :: Percentages & Empirical Formula
      • :: Empirical formula
    • IV. Solutions and Solubility >
      • :: Types of Solutions with Solubility Curves
      • :: Solubility Curve
    • V. Easy Tricks and Tips >
      • :: Tip to Molecular Shapes
      • Memorizing Bond Angles and Polarity
      • :: Chemistry Formulas
      • :: Trick Polyatomic ions
    • VI. General AP Concepts >
      • :: Potential Energy Diagrams
      • :: Haber-Bosch
      • :: Le Chatelier
      • :: Pressure & Moles
      • ::Rydberg's Constant vs Unit of Energy
      • :: Equilibrium and RICE Tables
      • :: Kinetics
      • Galvanic Cells
    • :: Flash cards
    • :: VSEPR
  • AP Stats
    • Chi-Squared Tests
    • Applications of Statistics
    • Standardized Scores
    • Distributions Transformations
  • AP Calc
    • DI Method - Tabular Integration
    • Polar Curves: Tangent Line and Slope
    • Riemann Sums: Left and Right Approximations
    • :: Conic Sections Flash cards
    • :: Parent Functions Flash cards
    • Worked Out Problems >
      • :: Worked Out Problems I
      • :: Worked Out Problems II
      • :: Worked Out Problems III
      • :: Worked Out Problems IV
      • :: Worked Out Problems V
      • :: Worked Out Problems VI
      • :: Worked Out Problems VII
      • :: Worked Out Problems VIII
      • :: Worked Out Problems IX
      • :: Worked Out Problems X
      • :: Worked Out Problems XI
      • :: Worked Out Problems XII
      • :: Worked Out Problems XIII
    • Applying Trig Identities
    • L'Hopital's Rule
    • Differences Between Conic Sections
    • Graphing Conic Sections
    • :: Pre-Calc - Trig Identities
    • Tangent & Normal Lines
    • Indefinite integrals: U Sub
    • Calculus Derivatives >
      • Product Rule
      • Quotient Rule
      • Chain Rule
  • AP CS A
    • Studying for AP CSA 2020
    • :: Control Structures
    • :: What is Networking
    • :: Recursion
    • :: While Do While Loops in Java
    • :: Interface in Java
    • :: ArrayLists
    • :: Java Naming Conventions
    • :: Logic Circuits
    • :: Getters and Setters
    • :: Binary & Hexadecimal
  • AP Español
    • AP Español Salsa
  • Arduino
    • Quick Look
    • Project #1: Blinking LED
    • Project #2: Button LED
    • Project #3: Flowing LED
    • Project #4: LCD Display
    • Project #5: Serial Monitor
  • App
    • AP Go Pow How?
    • AP Go Pow APP Page
  • Musings
    • :: Backward induction
    • :: what is ISS
    • :: Rotational Matrices
    • :: Primary v Secondary Pollutants
    • :: Black Hole
    • :: Covid-19 Hackathon
    • :: Evolution of Immunizations
    • :: Predictions of Diseases
    • :: Book List
    • :: Patterncount
    • :: Binary Classification
    • :: Cybersecurity
    • :: Self Similarity
    • :: Trig Identities
    • :: UIL Number S
    • :: Box Offensive Play
    • :: Why Card Trick Works
    • :: Easy Multiplication
  • AP CREDIT
  • About