SFAI Introduction to Electronics and Microcontrollers, Fall 2013

DT-111-01 (9381): Introduction to Electronics and Microcontrollers
Fall 2013
Monday, Wednesday 07:30PM – 10:15PM, Main Campus Building, Room 105
Instructor: Michael Shiloh mshiloh@sfai.edu
Office Hours: Monday, Wednesday 07:00PM – 07:30PM room 105

Course Website (this page):

Syllabus: The latest version is always here


  • Introduction to Arduino
  • Sensors and switches (and more Arduino)
  • Basic electronics and introduction to schematics
  • Motors
  • Simple interactive project
  • Arduino and high current, H-bridge
  • External circuits: Perforated board, prototyping shields
  • Interfacing to existing devices: Voltage and current isolation
  • Building blocks and block diagrams
  • Power supplies and regulators
  • Enclosures
  • System design: cable management, power distribution, documentation
  • Projects

Week 1 Monday, August 26


  • Review syllabus


  • Intro to Solderless Breadboard

Homework 1 due week 1 Wednesday, August 28

  • Bring in your laptops on Wednesday
  • 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
  • If you feel your math is weak, review. Kahn Academy is a great resource. A good discussion of scientific and engineering notation (and prefixes) is here. If you find better sources, please let me know.
  • Read the Arduino Blink tutorial

Week 1 Wednesday, August 28


  • Installation, blink
  • digitalWrite()
    • Review Blink sketch
    • Add an external LED, first by plugging directly in pin 13, then breadboard
  • 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
    • Photoresistor controls blink rate
    • Arduino->File->Examples->Analog->AnalogInput
    • Analog Input Tutorial

Homework 2 due week 2 Wednesday, September 4

  • Monday is Labor Day holiday
  • Review the Analog Input Tutorial to remind yourselves how the input from the light sensor changes the blink rate
  • 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. Verify your sketch by pressing the verify button. If you don’t have a computer,  you can do this on paper and then verify your sketch on the computers in the computer lab or check one out of the media room. They should all have Arduino installed. Email me your sketch, regardless of whether you were able to verify it or not.
  • Read the Button tutorial

Week 2 Wednesday, September 4


  • Review homework


  • Do the Button tutorial
  • Discuss bouncing and see if we can observe it
  • Fix the problem using the debounce tutorial
  • Add a second LED and explain how the LED can come on when the output is LOW
  • Modify the Blink sketch or the Analog Input sketch so button controls blink rate
  • Modify the Fade sketch so the button selects fade up or fade down

Homework 3 due week 3 Monday, September 9

Week 3 Monday, September 9


  • Electromagnetism
    • Solenoids
    • Relays
    • Motors
      • Stepper motors
      • Brushless DC (BLDC) motors
      • Brushed Permanent Magnet motors
      • Servo motors
  • Interfacing Arduino to motors
  • Interfacing Arduino to toys and other gadgets
  • Motor direction


  • Soldering
  • Measuring power supply voltage
  • Estimating motor voltage
  • Control motor with Arduino
  • Examples of back and forth motion

Homework 4 due week 3 Wednesday, September 11

Design a project based around a motor that is controlled by Arduino. Consider that you can control the motor speed as well as direction. Importantly, consider what happens when the motor goes as far as it should in either direction. How does it know to stop? Think about an electric garage door opener. Make sure to incorporate such safety features into your project.

Explore these links:

  • Learn about limit switches at Wikipedia
  • To get linear motion, you may use a threaded rod. Here is a simple picture showing the major components of such a mechanism. The full article is also informative.
  • See how the limit switches are used in these Instructions to make a linear actuator from a lip balm dispenser. In these case, the switch is composed of a magnetic sensor and a magnet

Sketch out your design, and be prepared to discuss it in class.

Week 3 Wednesday, September 11


  • No class Wednesday September 18. Free day to work on project. Extra lab time will be scheduled later in the semester.
  • Voltage and current
  • How to reverse a motor
    • Tutorial showing how to use H-bridge IC
    • Relays
  • How to prevent a motor from going too far in the wrong direction
    • Limit switch
    • Other type of position sensors

Week 4 Monday, September 16


  • Where are you on projects?
  • Who needs motors or power supplies?
  • Who  needs to reverse their motors?
  • Who needs to stop their motors?
  • Limit switches


  • Relays and H-bridges
  • Limit switches

Homework due Monday, September 30

  1. Watch this Khan Academy lesson on binary numbers. You might find this article helpful as well. Be prepared to convert numbers from binary to decimal, and decimal to binary.
  2. Read this short introduction to Boolean logic. Be prepared to explain AND, OR, and NOT.
  3. Preparing for your Halloween project:
    1. Browse these resources for a class on Mechanisms and Things that Move at NYU’s ITP
    2. Browse these resources for a Sensor workshop at ITP, including long list of different sensors
    3. 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)

Week 6 Monday, September 30


  1. Why do we care about binary numbers
  2. How do we count in binary
  3. What is Boolean logic (you may have used them when you search)
  4. Bitwise operators

Week 6 Wednesday, October 02


  • 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
    • Switches
    • Other (SPI, I2C, etc.)
  • Interfacing to existing devices
    • Output devices
      • Basically the same as controlling motors above (transistors, relays)
    • Input devices
      • Relays
      • Optoisolators
  • Sound
    • Simple tones
    • More complex tone generation
    • Recording and playback of short, low fidelity sound clips
    • High fidelity sound


  • 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; 
        PORTD = B00000100; 
        PORTD = B00010000; 
        PORTD = B01000000; 

      What is happening here?

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

      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; 

      What is happening here?

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

      What is happening here?

Homework due Monday, October 7

  1. 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.
  2. Read the Blink Without Delay tutorial
  3. Next week, we will use the principles in Blink Without Delay to do two things at once

Monday, October 7


  • Blink Without Delay
  • Soldering
    • Wires
    • Printed Circuit Boards
    • Perforated breadboards
  • 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


  • Identify a sensor or actuator in your device, and interface it to your Arduino
  • Use Blink Without Delay to both blink an LED and detect a sensor

Wednesday, October 9

Work on projects

Monday, October 14


  • Finish what I didn’t cover from 10/2 and 10/7
  • Communication: Graph and Dimmer
  • Shields
  • Proto Shield


  • Incorporate Blink Without Delay

Wednesday, October 16


  • Show how I use proto shield
  • Connectors
  • Power distribution and ground noise
  • Designing for reliabilty, robustness, ease of repair and modification
  • Avoiding stress in thin wires or other delicate components
    • Stranded vs. solid wire
    • Strain relief
    • Guiding and supporting wires around rotating or other moving parts

Monday, November 4


  • What we learned from projects
    • Avoiding bottlenecks
    • Recognizing building blocks
    • Build in steps and test each piece
    • What went wrong
      • Damaged devices due to wrong polarity, wrong voltage, wires falling off and not knowing where they belonged
      • Too complex to reuse
    • Debugging
      • Confirming voltage and polarity with a multimeter
      • Isolating stages (e.g. checking voltage at output of LM339, turning on transistor manually, Serial.println, etc.)
      • Multimeter for slow changing signals
      • Oscilloscope for audio or other rapidly changing signals


  • Communication
    • Run File -> Examples -> Communication -> Graph
      • Modify to take two sensors and draw in X and Y
      • Check sensor output with multimeter

Homework due Wednesday, November 6

Wednesday, November 6


  • Communication
    • Run File -> Examples -> Communication -> Dimmer
      • Change numbers to use command line instead of GUI
      • Check PWM output with multimeter
    •  Modify dimmer to control 3 values, and control an RGB LED
    • To the example in the first tutorial, use Arduino and a momentary switch instead of the mousePressed event

Homework due Monday, November 11

  • Design your final project:
    • Write up what you would like to do for your final project
    • 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.
    • 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.
    • You will still be learning new concepts through the rest of the semester, so be flexible in your project so that you can add new capabilities
    • 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.
  • Start working on your project. Be prepared to show and discuss progress at our next meeting. At this early stage, this can include research and identifying and ordering components or other parts

Monday, November 11

Field Trip

We will attend the SF Microcontroller Club meeting this Wednesday evening at Carl Pisaturo’s studio in the Mission. Be there at 7:30pm. The meeting lasts until about 10.

Area 2881 (aka Carl’s studio)
2881 23rd St

The nearest BART stop is 24th St Mission, about 9 blocks away. Parking is difficult so carpooling is encouraged.

Carl’s place is a museum of his amazing creations, so be sure to arrive on time so that you can look around before the meeting gets started.


  • While (myVar != 0); while (myVar); while (1);
  • Endless loops
  • File -> Example -> Control -> SwitchCase2
  • Multiplexing inputs and outputs with the 74ls595
  • Arduino function description


Homework due Wednesday, November 13

  • Remember to come to the field trip tomorrow (Wednesday)

Homework due Monday, November 18

  • Prepare a written description of your project. This can be electronic or paper. Since I will ask for ongoing status reports, you may find a blog to be useful.
  • Identify the major risks of your project. This includes non-technical risks such as time risks (something takes much longer than you expect), monetary risks (parts may be much more expensive that you expect), etc.
  • Identify the steps you will take before our next meeting to mitigate these risks e.g. order parts, prototype the parts you are unsure about, start building the structure you fear might take a long time, etc.
  • Create a rough weekly schedule for the remainder of the semester, showing how you will finish your project on time. We will review this at every meeting to see where we are.

Monday, November 25

Wednesday, November 27


  • Each of you must be working on this project on your own time, in addition to any lab time I give you
  • Should we have a public show on Wednesday December 4?


Monday, December 2


  • Each of you must be working on this project on your own time, in addition to any lab time I give you
  • Should we have a public show? John has offered us the space by the window at the bottom of the elevator/ramp, where the trashcans often sit. That space is being converted to a display area, and we would be the first to use it.
    If we want to do this, we need to:

    • Have projects completed and installed at a certain time, so that we can publicize the event
    • Create and put up some fliers
    • Mass emailing to SFAI community (I can do this)
    • Prepare refreshments (I can do this if we don’t go crazy)


  • Ryan must do his evaluation
  • Noah (or someone) must turn them all in


  • Interrupts


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 *