CCA Digital Electronics, Fall 2013

SCIMA-300-01 (773) Digital Electronics
Fall 2013
Wednesday 08:00AM – 11:00AM,
Main SF Bldg, Room 107 (Hybrid Lab)

Instructor: Michael Shiloh
mshiloh@cca.edu
Office hours: Mondays and Wednesdays 11-11:30 or by appointment
Course Description
Digital Electronics and Microcontrollers are increasingly becoming an important skill forartists, designers, and architects. Artists are embedding circuits into their work to create interactive art or kinetic sculpture. Architects are designing smart buildings that can adapt and change to environmental conditions. Designers are embedding electronics into products, fashion, and interactive displays to enhance the daily quality of our lives. Interfacing these devices to computers adds another dimension. This course is an introduction to digital electronics and microcontrollers for use in art and design. It will concentrate on the principles of digital electronics and microcontrollers, and of Arduino in particular, with the aim that you design and build your own circuits. Topics include basic electronic principles, logic, binary numbers and arithmetic, logic gates, and microcontrollers. We will build our own Arduino microcontroller system and learn how to program it to react to various sensors and control output devices such as motors and LED displays. Lectures and hands-on lab work, as well as a final project, will be the mode for this course. Labs will be strongly Arduino focused. An Arduino is included in course materials, along with various other components. A laptop is highly recommended.

Syllabus: The latest version is always here

How to succeed in this class

  1. Attend every meeting, even if you are tired, or it’s raining, or it’s sunny outside
  2. Do all the homework, even if there is something good on TV or your friends want to go bowling
  3. Use your resources: office hours, tutoring center, advisors, etc. You are paying for this whether you use it or not.
    1. You may work in groups as long as you all understand the process
    2. Visit me during my office hours
    3. Email me at other times
    4. Don’t wait until the last minute. I will probably not see your email on the night before the assignment is due
    5. Ask questions of the Hybrid Lab manager, his monitors, or other students in the lab
    6. Use the Arduino forum, and forums on other websites (Adafruit, Tronixstuff, etc.)
    7. Google! If you can’t find it you’re using the wrong keywords. Everything that can be done with Arduino has been done. (Not really true but prove me wrong.)

Kit Contents

  • Arduino Uno R3
  • USB cable
  • 400 point breadboard for rapid prototyping without soldering
  • Premium jumper wire value pack – combinations female/male, male/male in 6″ and 10″ lengths
  • 3 x 3 mm red LEDs
  • 3 x 3 mm yellow LEDs
  • 3 x 3 mm green LEDs
  • 3 x 5 mm red LEDs
  • 3 x 5 mm green LEDs
  • 9V battery case with 2.1mm plug for Arduino
  • 10 x 220 ohm resistors
  • 10 x 10K resistors
  • 10 x 1K resistors
  • Light dependent resistor (CdS cell)
  • Thermistor
  • 5-9V DC Motor with leads
  • Piezo buzzer – passive
  • 2 x MOSFET irlb8721pbf
  • L293D Stepper motor controller driver IC
  • 1 set stackable headers (2 x 8 pin, 2 x 6 pin)
  • Prototype shield bare board
  • 40 Pin header (male)

Week 1 Monday and Wednesday, September 4

Lecture

  • Review syllabus
  • Evaluation
    • Draw a picture of an atom and identify the electron and nucleus
    • Draw a picture of a battery, a light bulb, and wires so the light bulb is lit
    • X=39Y + 5. Solve for Y
    • X=5/(39+Y). Solve for Y
    • How many milliliters are in a 1.5 liter bottle of soda?
    • How man kilograms are there in a 750 milligram chocolate bar?
    • What is 7.5 x 10^3?
    • What is 9862 x 10^-3?
  • Basic circuit theory
    • Components
    • Connections
    • Circuits
    • Schematic Symbols
  • solderless breadboards

Lab

  • Solderless breadboard
  • Battery, resistor, LED
  • Multimeter

Homework 1 due week 2 , Wednesday, September 11

  • Purchase the required textbook: There Are No Electrons: Electronics for Earthlings (Clearwater Publishing) by Kenn Amdahl
    ISBN-10: 0962781592
    ISBN-13: 978-0962781599
  • Read in the book from the very beginning (About This Book) through page 33
  • Do either the even or odd exercises of these Basic Math Exercises
  • A good website for learning math (and in fact anything) is Khan Academy
  • A good discussion of scientific and engineering notation (and prefixes) is here

Week 2 Wednesday, September 11

Homework 15 minutes

  • Math review
  • Hand in homework

Review Questions

  • Who has the book?
  • Who did the reading?
  • What is the connection between sheep and static electricity?
  • Why where early electrical demonstrations done in the living room?
  • What is pith? Why was pith used?
  • How many different types of static electricity are there? What are they called?
  • What did Ben Franklin get wrong?
  • Is the electron theory a fact?
  • Which part of an atom moves? Why?
  • What are Greenies? What do they like to do?
  • What motivates Greenies to drive? Would Greenies drive otherwise?
  • What are voltage and current?
  • Can there be a voltage without current?
  • Can there be a current without voltage?
  • What are the units of voltage and current?
  • How many rivers come out of Lake Dubious? What are their differences?
  • What part of the river represents voltage? Current?
  • If more rivers leave Lake Dubious and end up at the ocean, but they take different paths, are their voltages similar or different? What about current?
  • What is voltage?
  • What is current?
  • Is voltage related to work? If the lake is higher, does more work get done by the river?
  • Is current related to work? If the river is wider, does more work get done by the river?
  • How do we calculate work? What are the units?
  • What is voltage?
  • What is current?

Lecture

Lab

  • Two resistors
  • Write everything down: measurements, draw circuit, etc.
    • How many different ways can you connect two resistors and one LED?
    • Measure resistance without battery
    • Add battery, observe effect on LED brightness
    • Measure voltage
    • Try to come up with rules

Lecture

  • Resistance
  • Ohm’s law
  • Look back at lab notes: What might account for different LED brightness?

Lab

  • Arduino kits

Homework 2 due week 3 , Wednesday, September 18

  • Create your own reference pages, either in your notebook or as a separate notebook. In your reference pages, explain the resistor color code and the engineering prefixes (milli, micro, Mega, etc.). You will show this to me but not hand it in.
  • Watch this Introduction to Arduino video
  • Read Lesson 0 Adafruit’s Arduino tutorials
  • Download and install as best you can, the Arduino IDE from here. Refer to Adafruit’s Lesson 0 as well as the Arduino Getting Started guide
  • Read the Arduino Blink tutorial
  • Read from page 34 to magnetism on page 41 in There Are No Electronics
  • Read tutorials 1-4 of Electronic Tutorials about DC Theory
  • Read Chapters 1-6 in Volume 1: DC of Basic Concepts of Electricity in All About Circuits, a free online text book
  • links to breadboard
  • Bring in your laptops next Wednesday
  • Extra resources on the solderless breadboard are here, here, and here. Let me know if you find these helpful or not helpful.

Week 3 , Wednesday, September 18

Homework 15 minutes

  • Hand in homework

Review Questions

  • What is voltage?
  • What is current?
  • If you have a battery connected to nothing, does current flow? Why not?
  • If you attach a resistor to a battery, what is the voltage on the resistor?
  • How much current flows in the resistor? In the battery?
  • If instead you attach a resistor of a different value, does the voltage on the resistor change? Does the current?
  • What is voltage?
  • What is current?
  • If both resistors are each attached to the battery, what is the voltage on each resistor? What is the current through each resistor? What is the current in the battery?
  • Remember the first lab we did (battery, LED, resistor). Is the current the same in the LED and resistor? What about the battery?
  • Can we calculate the current in the LED? Can we calculate the current in the battery? What about the resistor?
  • If we know the safe current for the LED, what resistor value should we use?
  • How would we connect two LEDs so that we could guarantee not to exceed the safe current of the LEDs? What about 3? What about 4? What about 12? What is the difference between the safe ways and the unsafe ways?
  • What value of resistor should we use in order to guarantee not to exceed the safe current of the LEDs?
  • Is there a limit to how many LEDs we can attach?
  • Suppose instead of a battery, the LEDs are controlled by Arduino. Is there a limit? Why?
  • How can we control more LEDs?

Lab

  • Installation, blink
  • digitalWrite()
    • Review Blink sketch
    • Add an external LED, first by plugging directly in pin 13, then breadboard
    • Actuators, and how Arduino controls them: HIGH and LOW voltage levels
  • Debugging skills
    • Incorrect circuitLoose wires
      • Confusion between rows and columns
      • Parallax
      • Wire color confusion
    • Faulty components
  • analogRead()
    • Sensors, and how Arduino reads them: Voltage (in contrast with actuators)
    • Photoresistor needs Voltage Divider to convert resistance to voltage
    • Arduino->File->Examples->Basics->AnalogReadSerial
    • Analog Read Serial tutorial
  • Linking input and output

Homework 3 due week 4 , Wednesday, September 25

  • Do the Fade Tutorial
  • Do the Analog Input Tutorial
  • Study the If Statement tutorial
  • Modify the Blink sketch or the Analog Input sketch so that if the light sensor reports a value greater than 500, the blink delay is 1000 msec, and if the light sensor reports a value less than 500, the blink delay is 100 msec.
  • You might find these resources useful: Adafruit Arduino Tutorials starting here,  this Introduction to Arduino video, this excellent introduction to Arduino: Arduino in a Nutshell

Week 4 Wednesday, September 25

Homework 15 minutes

  • How did you solve the homework exercise?

Review Questions

  1. Selected items from last week
  2. Schematic symbols

Lecture

  1. Arduino schematic
  2. ATMega328 pinout
  3. Why do we care about binary numbers?
  4. How do we count in binary?
  5. How do we indicate a number in a different base? Arduino Integer Constant reference
  6. What is Boolean logic (you may have used this e.g. when you search) Arduino Boolean Operators reference
  7. Conditional execution and the IF statement
  8. Looping and the FOR loop
  9. Boolean logic and conditional execution
  10. Bitwise operators Arduino Bitwise operators reference
  11. Data representation: numbers, characters, and strings; arrays

Lab

  • Document your work (schematics, explanations, etc.), answer the questions, and hand in your work
  • Observing binary numbers and bitwise operators using multiple LEDs and the PORT command:
    1. Connect LEDs to each of Port D’s pins. Don’t forget resistors.
    2. Why might this cause trouble uploading a sketch? What can you do to fix this?
    3. Run this program:
      void setup()
      { 
        DDRD = B11111111; // set all port D pins as OUTPUT
      } 
      
      void loop()
      { 
        PORTD = B00000001; 
        delay(1000);
        PORTD = B00000100; 
        delay(1000);
        PORTD = B00010000; 
        delay(1000);
        PORTD = B01000000; 
        delay(1000);
      }

      What is happening here?

    4. Run this program:
      void setup()
      { 
        DDRD = B11111111; // set all port D pins as OUTPUT
      } 
      
      void loop()
      { 
        PORTD = 0; 
        delay(1000);
        PORTD = 1; 
        delay(1000);
        PORTD = 2; 
        delay(1000);
        PORTD = 3; 
        delay(1000);  
        PORTD = 4; 
        delay(1000);  
        PORTD = 5; 
        delay(1000);  
        PORTD = 6; 
        delay(1000);  
        PORTD = 7; 
        delay(1000);
      }

      What is happening here?

    5. Run this program:
      void setup()
      { 
        DDRD = B11111111; // set all port D pins as OUTPUT
      } 
      
      void loop()
      { 
        for( int i = 0; i < 256; i = i + 1)
        {
          PORTD = i; 
          delay(300);
        }
      }

      What is happening here?

    6. Run this program:
      void setup()
      { 
        DDRD = B11111111; // set all port D pins as OUTPUT
        PORTD = b00000001; 
      } 
      
      void loop()
      { 
        delay(1000);
        PORTD = PORTD << 1;
      }

      What is happening here?

Homework 4 due week 5 , Wednesday, October 2

  1. Using binary numbers and bitwise operators, and the lab exercises, write a program that will make the 8 LEDs illuminate in “Knight Rider” or Cylon fashion i.e.
    .......*
    ......*.
    .....*..
    ....*...
    ...*....
    ..*.....
    .*......
    *.......
    .*......
    ..*.....
    ...*....
    ....*...
    .....*..
    ......*.
    .......*
    ......*.

    Hand in the schematic and the program, either on paper or electronically

  2. Add your photoresistor to the circuit, and write a program to create a bar graph display i.e.
    1. If there is very little light, do not illuminate any LEDs
    2. If there is a bit of light, illuminate one LED
    3. If there is more light, illuminate two LEDs
    4. etc.
    5. If there is a lot of light, illuminate all of the LEDs

    Hand in the schematic and the program, either on paper or electronically

  3. Read the Blink Without Delay tutorial

Week 5 , Wednesday, October 2

Lecture

  • Motors
    • Brushed DC
    • Stepper
    • Servo
    • AC
  • Sensing position
    • Continuous
      • optical encoder
      • resistive
    • Only at key spots (usually near end of travel)
      • Limit switch
      • Magnetic switch
  • Controlling motors and other high current, high voltage, or AC loads
    • Limitations
      • Current limitations
      • Voltage limitations
      • DC vs. AC
    • Solutions
      • Transistors
      • H-bridge
      • Relay,
        •  Using a transistor
        • Diode
      • Solid state relay
  • Sensors
    • Resistive
    • Analog voltage
    • Other (SPI, I2C, etc.)
  • Interfacing to existing devices
    • Output devices
      • Basically the same as controlling motors above (transistors, relays)
    • Input devices
      • Relays
      • Optoisolators

Homework 5 due week 6, Wednesday, October 9

  • Bring in a toy, device, appliance, gadget, Halloween prop, etc. that you don’t mind ruining. We will use this either as an input to or output from Arduino. You can purchase inexpensive electronic toys at thrift stores. It’s OK if the item doesn’t work – we will find something in it that does work and use that.
  • Read the Adafruit Guide to Excellent Soldering, including the troubleshooting section at the end
  • Browse these resources for a class on Mechanisms and Things that Move at NYU’s ITP
  • Browse these resources for a Sensor workshop at ITP, including a long list of different sensors
  • Read this pamphlet on how to hack toys and inexpensive devices to make your own Low tech Sensors and Actuators for Artists and Architects (16 page pdf)
  • Think about what you learned doing this reading in preparation for the Halloween project which will be due on 10/30

Next week:

  • Blink without delay
  • Lab time

Week 5, Wednesday, October 9

Lecture

  • Blink Without Delay
  • Soldering
    • Wires
    • Printed Circuit Boards
    • Perforated breadboard
  • Sensors
    • Identifying ground
    • Checking sensor voltage
    • Checking comparator voltage
    • Voltage divider to reduce voltage
    • Risk of going over
    • Risk of shared wires (human risk, circuit risk)
    • Isolation: relays, optoisolators
  • Actuators
    • Identifying ground
    • Checking actuator voltage
    • Using transistor to control higher voltage
    • Risk of shared wires (human risk, circuit risk)
    • Isolation: relays, optoisolators
  • Building blocks
    • Sensors
    • Actuators
    • Arduino software

Lab

  • Identify a sensor or actuator in your device, and interface to it

Homework 6 due week 7, Wednesday, October 16

Delayed to the following week

Week 6 , Wednesday, October 16

Lecture

  • Holiday, sick, travel, etc. policy: We will have class on Wednesday before Thanksgiving, and absence will be counted.
  • Fritzing
  • L293 motor controller tutorial
  • Proto shields

Homework 6 due week 8, Wednesday, October  23

  • Design and build an Arduino system consisting of two photoresistors, an LED, a motor, and a transistor. Use different inputs and outputs (you can choose which ones) for each device, and use the transistor for the motor.
  • Write a sketch which will do the following:
    • One photoresistor turns on the LED if the value is above some threshold, and turns on the motor if the value is below that threshold. Chose an appropriate threshold for your situation.
    • The second photoresistor controls the speed of the motor (but only when the first photoresistor’s value is below the threshold )
  • Document your sketch with meaningful comments. Don’t say “add 5 to sensorValue”; rather, explain why 5 is being added to the sensor value.
  • Create a schematic (in any way you wish) that documents your project
  • Be prepared to demonstrate your circuit, and hand in the schematic and sketch either electronically or on paper

Midterm status report due October 23

  • Describe the state of your project in a written report to be handed in, either electronically or on paper:
  • Your project does not need to be finished but should be getting close. Document your project:
    • Draw a schematic in any way you wish
    • Add descriptive comments to your program. Don’t say “add 5 to sensorValue”. Rather, explain why you are adding 5 to sensorValue.
    • Describe the overall design of your project.

Week 7 , Wednesday, October 23

Lecture

  • Tone tutorial and arrays, FOR loops, and functions
  • Proto shields examples
  • Something from the future, time permitting

Homework 7 due week 8, Wednesday, October  30

Your Halloween projects are due to be ready for critique by 9AM. N7, N9, N11, N15 walls with 3 tables and 20 chairs are reserved for our class. Please share the tables and wall space as needed. Your project must be functional and ready to set up at 8AM so that we can start critiques at 9AM. Attendance will be taken at 8:00 am as usual.

If you have questions you may email me, as usual.

Week 8, Wednesday, October 30

Critique

Homework 8 due Week 9, Wednesday, November 6

  1. Document your project. Email or hand in:
    1. Schematic
    2. Program (with descriptive comments)
    3. Brief description of what project does
    4. What things went wrong with your project, and how would you avoid them in the future? Be  specific. Itemize each issue and what you would do to mitigate that risk next time.
  2. Write up what you would like to do for your final project. Constraints are:
    1. Be prepared to work on your project outside of class time. We will have limited project time in class, but this should be reserved for problem solving. Be realistic about your intentions.
    2. Project must be more complex. This might involve more sensors and/or actuators, sensors or actuators of a more complex nature, and/or more complex behavior.
    3. Sketch up a very rough idea of your final project, so I can confirm this is sufficiently complex, and reasonably achievable. We will discuss in class.

Week 9, Wednesday, November 6

Lecture

  • What happens to your grade if you have more than 2 absences?
  • What happens to your grade if you have more than 4 absences?
  • What happens if you arrive more than 15 minutes late?
  • When is homework due?

Lab

  • Communication
    • Run File -> Examples -> Communication -> Graph

Homework 9 due Week 10, Wednesday, November 13

  • Start working on your projects. Identify the riskiest part of your project, and work to reduce that risk by doing research, prototyping, or  identifying and ordering components or other parts. Be prepared to show and discuss progress at our next meeting
  • Read either the  Arduino Shiftout tutorial from the beginning up to Example 2, or Arduino Lesson 4 from Adafruit
  • Read or watch one of these tutorials on how to use a multimeter: Youtube, SparkFun, or Adafruit
  • Read the Seven Segment Display Tutorial on Instructables up to step 6: Multiplexing
  • Read the Arduino Functions tutorial. If you are confused this Function Tutorial in the Arduino Playground (user submitted material) might explain things in a way that makes more sense to you
  • Read the Arduino Switch (case) Statement tutorial

Week 10, Wednesday, November 13

Review

  • Demonstrate your understanding of shift registers, 7 segment displays, functions, and the switch statement

Lecture

  • Matrix displays
  • While (myVar != 0); while (myVar); while (1);
  • Endless loops

Lab

  • Seven-segment display UC5621-11 (datasheet) (tutorial)
  • Matrix displays
  • Shift register 74HC595 (tutorial)
  • Interface a 7 segment display to an Arduino using a shift register.
  • After functional testing, control it from the Arduino IDE via the serial monitor (File -> Examples -> Communications -> switchCase2

Homework 10 due Week 11, Wednesday, November 20

  • Read Arduino Lesson 17 by Adafruit, showing you how to write a Python program that will send you email when it receives a message from Arduino
  • Your final project must not use the solderless breadboard. Be prepared to solder your project using a perforated breadboard or a prototyping shield. If you wish, you may practice by transferring the shift register and 7 seg display lab project to a prototyping shield.
  • Identify the next riskiest part of your project, and work to reduce that risk. By now you should be done with research, and should be prototyping further. Any components or other parts that that have long delivery times should be ordered. Be prepared to show and discuss progress at our next meeting

Week 11, Wednesday, November 20

Homework

  • Python gmail
    • Can you test this if you don’t have a PIR sensor?
    • why
      long lastSend =-minSecsBetweenEmails *1000l;
    • Why not just use delay()?
    • How can you test w/out Python?
    • What is Python?
    • What does this do:
       send_email():
    • What does this do:
       if message[0]=='M':
    • How can you test your Python program without Arduino?
  • Projects

Lecture

  • Interface show Friday December 13 7-10PM
  • extra lab hours
  • Policy on late assignments
  • Pathetic assignment timeliness, completeness, and  quality
  • Solderless breadboards
    • Bottom: side with donuts
    • Components, wires on  top
    • Solder on the bottom
    • Busses
    • Strain relief
  • IR Receiver TSOP4838 (datasheet) (example) (library) (another library)

Week 12, Wednesday, November 27

Announcements

  • You must work on your projects on your own time. Use class lab time for solving problems you could not solve on your own.
  • Interface show Friday December 13 7-10PM in Oakland. Access to Oliver Hall to set up for the Interface Show: Wednesday and Thursday evenings and Friday all day. Thursday day is also an option but you have to let me know.
  • If you will not present your project at the Interface Show, your project is due at 8:30am on Wednesday, December 11
  • If you will present your project at the Interface Show, your project is due at 7pm on FRIDAY, December 13 installed and working
  • Your project must be documented properly. The format will be to create an Instructable. Your Instructable must include a schematic, parts list, software, and any additional information required to reproduce your project. You do not need to give detailed assembly instructions of common steps, but anything unusual or tricky should be explained.

Lecture

  • Switches in parallel and pull up/pull down resistor
  • Totem pole output
  • Open collector outputs
  • Tristate outputs
  • MOSFETs vs. BJTs; NPN vs PNP

Follow up on topics raised in class

  • Link to the Creative Architecture Machines’ Google+ community, and blog post describing the goals of this advanced architecture studio
  • Wonderful video explaining how transistors work. Funny, short, and understandable
  • Field trip to my workshop on Treasure Island Sunday December 8 11am-3pm. Visit my workshop, get a tour of other projects in our warehouse, work on your project. Directions
  • 3D printing batteries
  • Pen writes in conductive ink
  • What does an integrated circuit look like inside? A fake ATmega328, and other integrated circuits, including an ATmega8 (used in the first series of Arduino)
  • Access to Oliver Hall to set up for the Interface Show: Wednesday and Thursday evenings and Friday all day. Thursday day is also an option but you have to let me know.

Possible future topics

  • What topics interest you?
  • Interrupts
  • 8 channel analog multiplexer/demultiplexer MC14051 (datasheet) (example)

Wednesday, December 11

  • Evaluations
  • For those of you not participating in the Interface show, you projects are due at 9:30AM today
  • Your Instructables are due on the Instructables website by Sunday 9AM, unless I have given you permission not to publish your documentation
  • Need a laptop, projector, locks, or other item for the Interface show? Contact Jessica Keck (jkeck@cca.edu) at the Oakland Media Center. The Media Center will be open Today-Thurs 8am-8pm and Friday 8am-6pm. Any equipment should be picked up or dropped off during those times. They will not be in over the weekend, but will be in next Monday, Dec. 16th., which is when you’ll have to return whatever you took.
  • Spread the word about the Interface show on Friday: Print and post the fliers below and promote the Facebook page

interfaceshowDD_SinterfaceshowDD_MinterfaceshowDD_L

Print Friendly
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Leave a Reply

Your email address will not be published. Required fields are marked *