Difference between revisions of "EGR 224/Arduino Interfacing With Hardware II"

From PrattWiki
Jump to navigation Jump to search
(Arduino Software Initialization)
Line 24: Line 24:
 
* Go to the Sketch menu, then pick Include Library.  If Keypad is already listed (likely near the bottom in the Contributed libraries section), the library is installed.
 
* Go to the Sketch menu, then pick Include Library.  If Keypad is already listed (likely near the bottom in the Contributed libraries section), the library is installed.
 
* If Keypad is not listed, go to Manage Libraries and type <code>keypad</code> in the search box.  Scroll down to the one named '''Keypad''' and install it.
 
* If Keypad is not listed, go to Manage Libraries and type <code>keypad</code> in the search box.  Scroll down to the one named '''Keypad''' and install it.
 +
 +
== Arduino Sketches ==
 +
To create a new sketch, go to File and then New.  The first time you want to upload and run a sketch, Arduino will ask you to save it somewhere.  You can save it wherever you like, though "Documents" would be a good choice.  Since these programs should already exist on Tinkercad, you will not be required to turn them in a second time.
  
 
== Required Parts ==
 
== Required Parts ==

Revision as of 15:31, 21 March 2023

Inventory

You need to check the inventory of your box before you begin the lab. You will also be required to check your box in with a TA before leaving. Failure to get your inventory checked will result in a grade of 0 for this lab! Your box should contain:

  • Arduino Uno
  • USB Cable for Arduino Uno
  • 4 470 $$\Omega$$ resistors (yellow-purple-brown-gold)
  • 1 15 k$$\Omega$$ resistor (brown-green-orange-gold)
  • 5 LEDs (clear, red, yellow, green, and blue)
  • 18 wires(2 each of red, orange, yellow, green, blue, purple, black, white, brown, gray)
  • 2 buttons (one white, one brown)
  • 4x4 keypad
  • 8-pin header
  • Breadboard
  • Screwdriver

If your box is missing anything or has anything extra, let a TA know at the start of lab to get your box in order.

Arduino Software Initialization

You may need to install the Arduino software on the computer. Search for "Arduino" - if nothing comes up as an installed program, go to Arduino Downloads and install the software.

Once installed. run it. A bank sketch should come up (or possibly the last sketch that was opened). Now connect the USB cable to your Arduino and then connect it to the computer. Wait for the computer to say it has finished recognizing / installing the Arduino. Once that is done, In the Arduino window, select the Tools menu, pick Board, and then find Arduino Uno or Arduino/Genuino Uno. Next go back to the Tools menu and select Port - there should be a COMN (Arduino/Genuino Uno). Finally from the File menu, pick Examples, 01.Basic, and Blink. Upload and run this on your board by clicking the right-arrow icon. After a few moments, the on-board light on the Uno should Blink. If that doesn't work, let a TA know.

Next, go to File, pick Examples, 01.Basic, and BareMinimum. Upload this to your Arduino. You should upload this sketch every time you plan to change the circuit connected to the Arduino so that all the pins are off.

Finally, to make the keypad work, you may need to install the Keypad.h library. To do that:

  • Go to the Sketch menu, then pick Include Library. If Keypad is already listed (likely near the bottom in the Contributed libraries section), the library is installed.
  • If Keypad is not listed, go to Manage Libraries and type keypad in the search box. Scroll down to the one named Keypad and install it.

Arduino Sketches

To create a new sketch, go to File and then New. The first time you want to upload and run a sketch, Arduino will ask you to save it somewhere. You can save it wherever you like, though "Documents" would be a good choice. Since these programs should already exist on Tinkercad, you will not be required to turn them in a second time.

Required Parts

All parts of the lab will require the Arduino, Arduino cable, and breadboard. Note: replace "small" resistors in the tutorials (220 $$ \Omega$$) with the 470 $$\Omega$$ resistors and replace the "large" resistor (10 k$$\Omega$$) with the 15 k$$\Omega$$ resistor.

Blink an LED

  • 1 470 $$\Omega$$ resistor
  • Red LED
  • 3 wires

Multiple LEDs

  • 3 470 $$\Omega$$ resistors
  • Red, Yellow, and Green LEDs
  • 5 wires

Pushbutton

  • 1 470 $$\Omega$$ resistor
  • 1 15 k$$\Omega$$ resistor
  • Red LED
  • 4 wires
  • Pushbutton

Traffic Signal

  • 3 470 $$\Omega$$ resistors
  • Red, Yellow, and Green LEDs
  • 7 wires (or connect short lead of LED to the ground rail directly, eliminating the need for three of the wires)

Keypad and DEC TO BIN

  • 3 470 $$\Omega$$ resistors
  • Red, Blue, and Yellow LEDs
  • 14 wires (or connect short lead of LEDs to the ground rail directly, eliminating the need for three of the wires)
    • Use 7 wires to connect the left seven leads from the keypad to pins 2-8. You will not be using the far-right eighth lead on the keypad (this senses the right ABCD column, which we are not using).