Section outline

    • Assignment #2 -

      Parts: 1 Breadboard, 1 Red LED, 1 Yellow LED, 1 Green LED, 3 resistors (220 ohm red, red, brn, gold),  at least 8 jumper wires

      In Class We'll Discuss:
        - CQCQ - Link
        -Morse Code to 800 hz - Link
       
        -LEDs and Resistor Codes
        -Calculating Current Limiting resistor values in ohms 

      (

      Ω

      ) - 

      Ohm's Law  V=I R
               10mA at 5 Volt, 20mA at 5 Volt, Current at 5 Volts and 220 ohms
      ** Note: Arduino Digital Pins can safely output a maximum of 40 mA 
                


      Can't Resist

       











      -Comic Strip Pages 10 - 11 - Wiring LEDs on a breadboard

       
      - Don't let the Smoke Out !!! - Use only prescribed wiring !

      - Wire with the Power OFF (USB unplugged)


      With no Power to your Arduino:
      Wire 3 LEDs (with 3 Current Limiting Resistors) to Pins 4,5,6
      Pin4 to Resistor1.1 (resistor 1 - wire 1)
      Resistor1.2 to LED+ (resistor 1 - wire 2)
      LED- to Gnd

      Pin5 to Resistor2.1 (resistor 2 - wire 1)
      Resistor2.2 to LED+ (resistor 2 - wire 2)
      LED- to Gnd

      Pin6 to Resistor3.1 (resistor 3 - wire 1)
      Resistor3.2 to LED+ (resistor 3 - wire 2)
      LED- to Gnd

      Schematic

      1) Modify Blink to test each LED

      2) Write a program to simulate a traffic light.
      Green for 10 Seconds
      Yellow for 2 Seconds
      Red for 5 Seconds

      Add comment lines to the top of your program to explain what is wired to the Arduino






      Stoplight


    • ...

      Assignment 4 - Sound


      New parts: Speaker, CdS photoresistor, 10k Resistor (Br, Bl, Or, Gold)

      In Class:

      coil

      How a speaker works.

      Review Resistor Circuits:

      Current Limiting, Pull Down, Voltage Divider (Potentiometer), Pull Up

      See How a light sensitive resistor can create "Music":

       Examples - Basic - AnalogReadSerial -Determine range of A0 

        Examples - Digital - TonePitchFollower- Adjust to Pin 8 - Adjust to range of A0

       * 8-ohm speaker on digital pin 8 and Gnd

       * photoresistor on analog 0 to Gnd
       * 10K resistor (brown, black, red)  on analog 0 to 5v


      circuit

      Assignment:

      Write a program (sketch) that plays a song.

      Use the following as a guide:

      C Scale

      Note Values


      Table of Musical Frequencies
      Note Frequency Note Frequency Note Frequency
      C 130.82 C 261.63 C 523.25
      C# 138.59 C# 277.18 C# 554.37
      D 146.83 D 293.66 D 587.33
      D# 155.56 D# 311.13 D# 622.25
      E 164.81 E 329.63 E 659.26
      F 174.61 F 349.23 F 698.46
      F# 185 F# 369.99 F# 739.99
      G 196 G 392 G 783.99
      G# 207.65 G# 415.3 G# 830.61
      A 220 A 440 A 880
      A# 233.08 A# 466.16 A# 932.33
      B 246.94 B 493.88 B 987.77

      Treble and Bass Clefs

      Chromatic Scale - Link

    • Arduino Code to play the Chromatic Scale

    • For Duino app:
      Have your project open
      Click Libraries
      Search for FastLED
      Click Add

      Arduino Web Editor:
      FastLED should be preinstalled

      For Arduino PC/Mac app:
      Download FastLED library Here
      Click Libraries
      Beside Library Manager Click Import
      Upload the FastLED-3.2.1.zip


      Click FastLED Blink - Link


      1) Get 1 LED Blinking
      2) Blink All LEDs RED
      3) Blink All LEDS another Color

      Click FastLED Random Color Blink Code - Link

      Note: Num_LEDS variable, DATA_PIN variable, leds[NUM_LEDS] array, use FastLED.addLeds<NeoPixel...

      CRGB Defined Colors Link

      (Note Bottom of the WebPage Chart of Colors - may not reproduce accurately - varies with LED Strip)


      Assignment:

      Create a sketch that:

      1)  Lights all 7 lights the same color for 3 seconds, then changes all to another color (repeat until 6 colors have been shown)

      2) Lights each LED with a different color for 2 seconds (repeat for 6 color combinations)


      Extra Credit:

      Write a creative sketch for Mikey.

    • Assignment #6 -

      Christmas Lights - Arduino

       

      In Class We'll Discuss:

      Pulse Width Modulation Dimming:     Link to Reference:

      Adjusting the time on and time off to affect apparent brightness

       

       

      For-Loops           Link to Reference:

      for (int x=1; x<26; x++)

      {

      <code you want repeated>

      }

       

      Do While Loops   Link to Reference:

      x=1;

      do

      {

      <code you want repeated>

      x = x+1;

      } while (x < 26);


      While Loops       Link to Reference:

       

      while (x < 26)

      {

      <code you want repeated>

      x = x+1;

      }

      x=1;

       

      Make a 30 second repeating Christmas Star Routine:

      - include dimming

      Pin3 - Output (outer green star)

      Pin5 - Output (middle red star)

      Pin6 - Output (inner blue star)

      Pins 3,5,and 6 were used because they are PWM capable outputs.


      Wire 3 LEDs - 1 to each of pins 3,5,6 with current limiting resistors to test your code. (Note the wiring for the Stop Light and change to pins 3,5,6)


       
    • Applications of MicroControllers:

       
      MicroControllers Measure and Control 
      A 3D printer:
       - Measures temperatures of the extruder and print bed
       - Measures the extreme positions of the X,Y,Z axes (limiting switches)
       - Controls 4 stepper motors - X,Y,Z and extruder
       

      3-D Printing:
       
      Solidoodle 2


      Solidoodle 2


      Solidoodle 2




       
    •  
      Elegoo Neptune - Print Sample

      Discuss: Pawn and Card-Holder-IOTA

      Rotate:
      rotate([45,45,45]){
      cube([30, 40,30], center = true);
      }


      1) Online OpenSCAD - OpenSCAD Cloud

      2) Online OpenSCAD

      3) Online OpenSCAD  


      OpenSCAD Cheatsheet


      1. Create object
      2. Store Code in Arduino Web Editor
      3. Convert to  STL
      4. Name file: username-title  i.e. jrich-castle
      5. Upload  stl file to Google Drive (link Below)
      6. Create a Google Doc with your Openscad Code in the same Google Drive
      7. email support@blackhawkchristian.org that you have a 3D print job ready
      https://drive.google.com/drive/folders/0B1nHub4i4-YxekRwVHpOektHYWc?usp=sharing
       
       
      Assignment 7:
      Create a small Castle with Towers,  Battlements and a Wall.
      Max Dimensions:  66mm x 66mm x 66mm (~ 2.5" Cube)


      castle1

      castle2

      castle3



    • Turn in All but the Arduino and USB
      Get LCD, Ultrasonic Rangefinder and 4 patch cables

      Demo: Ultrasonic Acoustic Levitation

      Video Explaining Ultrasonic Levitation

      Ultrasonic Range Finders

       



      Install the HC-SR04 Rangefinder
      Note the Pin assignments on the HC-SR04
       
      4 Wires:
       
      HC-SR04 to Arduino
       
      1) Vcc to 5v
      2) Trig to Pin A5 
      3) Echo to Pin A4
      4) Gnd to Gnd

      Copy the program below into a blank Arduino sketch.

      Save as HC-SR04-LCD

      #include <LiquidCrystal.h>
      #define trigPin A5
      #define echoPin A4
      LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
      void setup()
      {
        pinMode(trigPin, OUTPUT);
        pinMode(echoPin, INPUT);
        lcd.begin(16, 2);              // start the library
        lcd.setCursor(0, 1);
        lcd.print("        HC-SR04         ");
      }
      void loop()
      {
      lcd.setCursor(0, 0);    
          int duration, distance;
          digitalWrite(trigPin, HIGH);
          delayMicroseconds(1000);
          digitalWrite(trigPin, LOW);
          duration = pulseIn(echoPin, HIGH);
          distance = (duration/2) / 29.1; 
              lcd.print(distance);
              lcd.print(" cm             ");
              delay (500); 
      }

      Upload the program
      Read distance on LCD Screen
       
      Activities:
      1) Set the HC-SR04 sensor 10 cm from a large flat surface. 
       
      Note the location of 0 cm on the sensor.
       
      (Front Edge?, at PC Board?, 1/2 way to PC Board?...)
       
       
      2) Measure 8 known distances and record sensor reading.
       
      Calculate % error = 100(a-e)/a where a = accepted, e = experimental
      3) What are the shortest and longest distances the Ultrasonic measures accurately?
      4) Are there surfaces that are "invisible" to the sensor?  (absorb the sound and give erroneous readings?)

      5) Extra Credit:
      Create a program to scroll an Appropriate message across the LCD display.

      :-)

       
       
       
       
       
    • Temperature and Humidity with an AHT20 Sensor

      Review:

      Microcontrollers M _________and C_________

      You have measured:

      • switch condition (on/off) 
      • voltage (potentiometer)
      • distance
      • time (with software)
      • temperature
      • humidity

      You have controlled:

      • LED (on/off)
      • LED brightness (PWM)
      • speaker (frequency, duration)
      • LED strip (color and brightness)

      types of resistor circuits:
      Current LimitingPull DownVoltage Divider (Potentiometer)Pull Up

      Fun Fact:

      Relative Humidity (%) is a measure of how close air is to being saturated with water vapor.
      Cold air can hold less water vapor than warm air
      so... as temp increases Rh(%) decreases - if water content stays the same
      as temp decreases Rh(%) increases - if water content stays the same

      Temp and Humidity Grapgh


      New Parts : AHT20 Temp & Humidity Sensor (4 Leads

      LED Cup Holder

      Demo AHT20 - Link


      Breadboard Circuit:


      LCD Circuit: 

      AHT20 Pin --- Arduino Pin

              Vin         ---     5v

             Gnd        ---     Gnd

             SCL        ---     A5    (SCL)

             SCA        ---     A4   (SCA)



      Program to test the AHT20 writing data to the serial monitor:

      Click Here for Test Program


      Load this Analog Read Code to see how buttons on LCD are encoded to A0:

      Click Here for Analog Read of A0


      Load this program to exercise the LCD with Buttons:

      Click Here for LCD Button Read

      Assignment:

      Create a sketch that:

      Reads Temp and Humidity(%) and prints the Temp (F) and Humidity (%)

      When the "Up" Button is pressed the Temp (C) is displayed for 2 seconds instead of Temp (F)

      When the "Down" Button is pressed the Temp (K) is displayed for 2 seconds instead of Temp (F)

      When the "Left" Button is pressed the LCD displays a NICE message to Mr. Suvar


      Notes:  F = 9/5 C + 32
                    K = C+273


      Temp variables should be floating point (not integer)

    • Elegoo Robot - V4


      Elegoo Robot

      * Arduino Based
      * 4 DC Motors with Motor Control Circuit
      * 3 IR Trackers
      * 1 Ultrasonic Range Finder


      ** contains other functions not used in our projects


      Battery Care/Use:

      Plug in after each use:


      Uploading: Turn Robot Power Off - Upload while on stand with wheels elevated.


      Tools: Allen Wrench (Hex Key) , Phillips Screw Driver, Hemostats


      Assembly of Elegoo V4


      Arduino Create Web Editor


      Text Editor

      CodeBender





  • Driving - Curves

     

    Elegoo Robot

    • BCS Robot Sumo Wrestling Rules


      Tournament:

      -          Double Elimination (Must lose twice to be eliminated)

      -          Random Initial Pairing

      Matches:

      -          Up to 3 minutes in duration

      -          Winner is the best of 3 Bouts

      -          Winning the match moves the robot ahead in the pairings

      -          Ties are decided by the judge

      Bouts:

      -          Robots start mid ring, beside each other, facing opposite directions

      -          Left/Right Side placement switches after each Bout

      -          A Robot wins a Bout when its opponent leaves the ring (touches the floor)

      -          Ties are decided by the judge

      -          Any parts coming off a robot during a Bout cause it to forfeit that Bout

      -          An extended "dance" may be stopped by mutual consent or judge's decision- restarting at center ring

      Sportsmanship:

      -          No Robot (or participant) may intentionally harm another robot (or participant)

      -          Cheering for your robot is encouraged

      Robot Specifications:

      -          Size  – Standard Elegoo V4 Robot

      -          Weight – Standard Elegoo V4 Robot

      -          need to be autonomous (programmed to make their own decisions)

      -          need a 5 second programmed delay after power up