CCA Programming and Electronics, Spring 2014

SCIMA-212-011 Programming and Electronics
Spring 2014
Monday 08:00AM – 11:00AM
Main SF Bldg, Room 107 (Hybrid Lab)

Jump to current homework assignment
Jump to LED matrix resources

Instructor: Michael Shiloh
mshiloh@cca.edu
Office hours: Mondays and Wednesdays 11-11:30 or by appointment

Programming coach:

Schedule a meeting with Colin Willson at meetme.so/ColinWillson
Mon.: 1:30 – 3:00 p.m.
Tues.: 10:00 a.m. – 12:00 p.m.
Wed., Thurs.: 10:00 a.m. – 4:00 p.m.
Fri.: 10:00 a.m. – 5:30 p.m.
Sat.: 11:00 a.m. – 2:00 p.m.
Sun.: 12:00 – 3:00 p.m.

Course Description
This course will introduce students to practical applications of physics, programming, and electronics by designing and building robust and functional interactive electromechanical devices. This course will cover basic elements of programming (Processing and Arduino), electronics (basic circuits, Arduino, sensors and actuators), and physics (mechanics, dynamics, energy conversion, and structural forces). Concepts in math and physics will be reinforced through their application in designing, building, and programming electronic and electromechanical projects. The course assumes high school level competence in algebra and trigonometry. A laptop is highly recommended

Syllabus: The latest version is always here: Class specific part and generic part

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 these whether you use them 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.)

Week 2 Monday, January 27

Lecture

  • Review syllabus
  • Where are you
    • programming
    • electronics
    • physics
    • math
  • Intro to Processing
    • Examples
      • planets
      • http://processing.org/examples/
        • form -> star
        • basics -> transform -> arm
        • structures -> createGraphics
      • Explore; What did you find that was cool?
    • Intro to programming
      • Analogy: washing hair
      • Processing:
        • sketch_001:
          void setup() {
            // parameters are x coordinate, y coordinate, x size, y size
            ellipse( 15, 15, 30, 30);
          }
        • sketch_002 change size of canvas:
          void setup() {
          
            // size of canvas (x, y)
            size(1024, 768);
          
            ellipse( 100, 200, 30, 30);
            // can change location and size
            // can also make multiple objects
          }
        • sketch_003 mouse variables, draw function:
          void setup() {
            size(1024, 768);
          } 
          
          // draw() is like making a drawing on a new
          // page in a flip book
          void draw(){
          
            // draw circle wherever the mouse is
            ellipse( mouseX, mouseY, 30, 30);
          }
        • sketch_004 our own variable that varies with every frame:
          void setup() {
            size(1024, 768);
          } 
          
          int myX = 0; // Create a variable and put 0 in it
          
          void draw(){
            // draw circle 
            ellipse( myX, 300, 30, 30);
          
            // change the x coordinate so on the next frame 
            // it will be in a different place; this makes
            // it appear to move
            myX = myX + 1;
          }
        • sketch_005 change color of pen; erase behind us:
          void setup() {
            size(1024, 768);
            // change color of pen
            stroke(255,0,0);
          } 
          
          int myX = 0;
          
          void draw(){  
            // clear the background before drawing each frame
            background(255);
          
            // draw circle 
            ellipse( myX, 300, 100, 100);
          
            // change the x number so next frame it will 
            // be in a different place
            myX = myX + 1;
          }

Lab

Homework 1 due week 3 , Monday, February 3

  1. Install the following:
    1. Processing
    2. Arduino
    3. Fritzing
  2. Read and do these tutorials. Take notes, write down questions, and be prepared to discuss in class:
    1. Hello Processing
    2. Getting Started
    3. Coordinate System and Shapes
    4. Color
  3. Write a processing program which will create a simple drawing using lines, ellipses, and rectangles, and whatever else you want. Your picture should include all three of the following:
    1. Some of it should be static
    2. Some of it should change depending on mouse position and/or button clicks, like example sketch_003 I showed in class
    3. Some of it should change with every frame, like example sketch_004 or sketch_005 I showed in class

    The change can be to position, size, shape, etc. of any of the objects in your picture

  4. Make sure your name is in your program
  5. Email your program to me by the due date

Week 3 , Monday, February 3

Lecture

  • Introduction to Electronics
  • Software vs. Hardware (Programming vs. Electronics)
  • Introduction to Arduino

Lab

Homework 2 due week 4 , Monday, February 10

  • Reading
  • Doing
  • What you have to hand in
    • You don’t need to hand in anything, but remember what I said in class: It is important that you understand what you are doing. I will ask you questions in class, and if you don’t do the tutorials and, most importantly, think about and understand what you did, I will find out. Your grade for this assignment will be based on your understanding and your ability to answer my questions
    • I encourage you to discuss the tutorials amongst yourselves and others, to clarify your understanding and your ability to explain it in your own words

Week 4 , Monday, February 10

Review Questions

  1. What is digitalRead() used for? What are the parameters to digitalRead()?
  2. digitalWrite()?
  3. analogRead()? Range?
  4. analogWrite()? Range?
  5. pinMode()?
  6. delay()?
  7. Serial.begin()?
  8. Serial.println()?
  9. map()?
  10. Why is digitalRead() red in the Arduino IDE?
  11. Why do you need a variable when using analogRead()?
  12. Why do you need a resistor when using a switch, as in the Digital Read tutorial?
  13. Why do you need a resistor when using an LED, as in the Fade tutorial?
  14. What does the if() statement do in the Fade tutorial?
  15. Identify these schematic symbols:
  16. What is the resistor color code?
  17. What value is a resistor whose colors are red-red-orange?
  18. brown-black-green?
  19. What colors are the bands for a resistor whose value is 820 Ohms?
  20. 1.2K?
  21. 10 Ohms?
  22. 330K?
  23. What is voltage?
  24. What is current?
  25. What is resistance?
  26. Can you have a voltage without a closed circuit?
  27. Can you have a resistance without a closed circuit?
  28. Can you have a current without a closed circuit?
  29. (Circuit with 12V battery and multiple nodes.) Identify nodes that have the same voltage and components that have the same current
  30. (Circuit) What is the voltage drop along a piece of wire?
  31. (Circuit) What is the power dissipated along a piece of wire?
  32. What is the current flowing through an open circuit?
  33. What is Ohm’s Law?
  34. How is power calculated?
  35. Why do we care about power?
  36. What is the current in a circuit consisting of a 9V battery and a 20K Ohm resistor?
  37. How much power is the resistor dissipating? How much power is the battery providing?
  38. What  value of resistor would you need to create a current of 100 mA if you had a 6V battery?
  39. How much power is the resistor dissipating? How much power is the battery providing?
  40. What would be the voltage drop on a resistor of value 980K Ohm if a current of 10 uA is flowing through it?
  41. How much power is the resistor dissipating? How much power is the battery providing?

Homework feedback

  1. Read the instructions very carefully and be sure to do all the parts, or else you will not receive full credit
  2. If a program, put your name in the file (as comments) and put your name in the file name

Lab

  1. Processing and Arduino together:
    1. Graph tutorial
    2. Dimmer tutorial

Lecture

  • We can view the numbers coming from Arduino in the Graph example using the serial monitor. Can we do the same the other way with Dimmer?
  • The difference between ASCII codes and raw numbers
  • Serial.read() always returns one byte, no matter how much data is waiting. What is a byte?
  • Definitions: bits, bytes, and representing numbers in binary
  • (How high can you count with a byte?)
  • (How do you represent a number bigger than 256? int, long, and float)
  • Back to serial and ASCII, and how to convert between ASCII and raw numbers

Lab

Homework 3 due week 5 , Monday, February 17

  1. Starting with the Graph tutorial, modify the Processing sketch so that the line is in a fixed location (not moving), but changes height according to the potentiometer on the Arduino. You will need to erase the line in every frame. You can get a potentiometer in the Hybrid Lab and do this at home if you want, or do this in the lab.
  2. Starting with the Dimmer tutorial, modify either the Processing sketch or the Arduino sketch so that when the mouse is in one half of the window the LED turns on, and when the mouse is in the other half of the window the LED turns off. You can use the LED that is on the Arduino so you don’t need any new components.
  3. Email to me your modified sketches. Remember to put your name in the file (as comments) and put your name in the file name as well e.g. michael_shiloh_homework_3_graph.pde
  4. Remember that I have office hours on Wednesday. Please come if you have any questions, want to review what we did in class, or want to do your homework with me nearby.
  5. Remember that you can also send me questions via email

Week 5 , Monday, February 17

Lecture

  • Animate a “ball”
    int xPos, yPos;        // the ball's horizontal and vertical positions
    
    void setup() {
      size(640, 480);       // set the size of the applet window
      // initialize the ball in the center of the screen:
      xPos = 0;
      yPos = 0;
    }
    
    void draw() {
      background(0); // clear the screen  
      fill(255);
    
      // update the ball position. This is how the ball is moved
      xPos = xPos + 1;
      yPos = yPos + 1;
    
      // Draw the ball:
      rect(xPos, yPos, 10, 10);
    }
  • Have the ball bounce off the walls, ceiling, floor
    int xDirection = 1;    // the ball's horizontal direction. left is –1, right is 1.
    int yDirection = 1;    // the ball's vertical direction. up is –1, down is 1.
    int xPos, yPos;        // the ball's horizontal and vertical positions
    
    void setup() {
      size(640, 480);       // set the size of the applet window
      // initialize the ball in the center of the screen:
      xPos = width/2;
      yPos = height/2;
    }
    
    void draw() {
      background(0); // clear the screen  
      fill(255);
    
      // stop the ball going off the left or right of the screen:
      if ( (xPos <= 0) ||  (xPos >= width) )
      { // reverse the ball's X direction 
        xDirection = -xDirection;               
      }
    
      // stop the ball going off the top or the bottom of the screen:
      if ((yPos <= 0) || (yPos >=height)) 
      { // reverse the y direction of the ball:
        yDirection = -yDirection;
      }
    
      // update the ball position. This is how the ball is moved
      xPos = xPos + xDirection;
      yPos = yPos + yDirection;
    
      // Draw the ball:
      rect(xPos, yPos, 10, 10);
    }
  • Add a paddle
    import java.awt.Rectangle;               // import Java's Rectangle class
    Rectangle leftPaddle;
    
    int xDirection = 1;    // the ball's horizontal direction. left is –1, right is 1.
    int yDirection = 1;    // the ball's vertical direction. up is –1, down is 1.
    int xPos, yPos;        // the ball's horizontal and vertical positions
    
    void setup() {
      size(640, 480);       // set the size of the applet window
      // initialize the ball in the center of the screen:
      xPos = width/2;
      yPos = height/2;
    
      leftPaddle = new Rectangle(100, height/2, 10, 400);
    }
    
    void draw() {
      background(0); // clear the screen  
      fill(255);
    
      rect(leftPaddle.x, leftPaddle.y, leftPaddle.width, leftPaddle.height);
      if (leftPaddle.contains(xPos, yPos)) 
      {
        xDirection = -xDirection; 
      }  
    
      // stop the ball going off the left or right of the screen:
      if ( (xPos <= 0) ||  (xPos >= width) )
      { // reverse the ball's X direction 
        xDirection = -xDirection;               
      }
    
      // stop the ball going off the top or the bottom of the screen:
      if ((yPos <= 0) || (yPos >=height)) 
      { // reverse the y direction of the ball:
        yDirection = -yDirection;
      }
    
      // update the ball position. This is how the ball is moved
      xPos = xPos + xDirection;
      yPos = yPos + yDirection;
    
      // Draw the ball:
      rect(xPos, yPos, 10, 10);
    }
  • Control the paddle with a mouse
    rect(leftPaddle.x, mouseY, leftPaddle.width, leftPaddle.height);
  • Instead of the mouse, use Arduino
    void serialEvent(Serial thisPort) {
    ...
    leftPaddle.y = int(map(inByte, 0, 1023, 0, height - leftPaddle.height));
  • Multiple players: Arduino Processing Pong
    1. Sending data from multiple sensors
      Serial.print() Serial.println()
    2. Creating functions
       resetBall();
       animateBall();
    3. Arrays and split()
      int sensors[] = int(split(inputString, ','));

Lab

Homework 4 due week 6 , Monday, February 24

  1. Do the Arduino example in File -> Examples -> Communication -> SerialCallResponseASCII. As before, it consists of both an Arduino sketch and a Processing sketch. There is also a link to a tutorial which will provide a little more information.
    You will have to build a circuit with two potentiometers and one pushbutton. If you don’t have a pushbutton, you can simply put a wire in the digital input (pin 2) and connect it directly to either 5V or GND, which is what the pushbutton would do.
  2. That there are two errors in the Processing sketch of this example. You will need to fix them:
    1. In serialEvent(), the input (myString) is trimmed without checking first to make sure that the string isn’t null. Compare carefully with the built-in Graph example or with the Arduino Processing Pong example we studied in class, and fix this problem
    2. The foreground color (fgcolor) is either black or white, depending on the value of the pushbutton (the third sensor value), but the background color (bgcolor) is never set. Set the background color to grey so that the ellipse is always visible, whether it is black or white.
  3. Write an explanation, in your own words, of what is going on. Most importantly, explain what is meant by call-and-response handshaking and how it is implemented in both the Processing and in the Arduino sketches.
  4. Why do you think the handshaking is necessary?
  5. Send me your repaired Processing sketch, your explanation, and your answer to the question.
  6. Remember to put your name in your Processing program

Week 6 , Monday, February 24

Homework review and grades

Midterm project

Lecture

  • Sensors
    • Resistive
    • Analog
      • Voltage
      • Serial (I2C, SPI, “serial”, other)
      • Parallel
      • PWM
    • Binary (usually called digital)
      • Switches
        • Toggle
        • Momentary
      • Complex sensors that result in a binary value
    • Other?
  • Actuators
    • Powered by Arduino pin
      • LED
      • Speaker (but…)
      • Relay (but …)
    • Powered elsewhere and controlled by Arduino
      • Servo
    • Powered elsewhere and switched by Arduino
      • Transistor
      • Relay
  • Physics
    • Gravity
      • How would gravity affect a bouncing ball?
      • How would gravity affect our Pong game?
    • Friction
      • How would friction affect a falling ball?

Lab

// Based on Example 5-9: Simple Gravity by Daniel Shiffman

/* 
Drop a ball from the ceiling

The default frame rate is 60 frames per second. 
that means that each frame is 1/60th of a second

During each frame, the ball moves and speeds up

finalY = initialY + 
         (initialVelocity * time) + 
         1/2(acceleration * (time)^2)

finalVelocity = initialVelocity + acceleration * time
*/
float posX = 100;        // Move to the middle of the window
float posY = 0;          // Remember zero is the top
float velocity = 0;      // Initial velocity
float acceleration = 10; // Gravity is 10 m/sec^2
float time = 1.0/60.0;   // Force numbers to be interpreted as floats 

void setup() {
  size(200,200);
  fill(175);
  stroke(0);
  rectMode(CENTER);
}

void draw() {
  background(255);         // clear the background
  rect(posX,posY,10,10);   // Display the square

  posY = posY +   // Calculate the new position
         (velocity * time) + 
         (1/2)*(acceleration * time * time);

  velocity = velocity + acceleration * time; // and the new velocity

  // If we reach the bottom, reverse velocity
  if (posY > height) {
    velocity = -0.95 * velocity;  // bounce isn't perfect; lost energy
  }
}

Add this to Pong to allow gravity to affect the ball

Homework due Week 7 , Monday, March 3

  1. Sketch out an idea for your midterm project. Email to me, and be prepared to discuss in class, your project concept, list of parts, and behavior. Start working on the project before next Monday and bring your partial work so that I can answer questions and help you in class. You will have time to work on your project next Monday.
  2. The midterm project will be due on Sunday, March 9, at 9am. As per the syllabus, late work will not be accepted.
  3. You project must include some of things we’ve learned or that you have learned on your own. A partial list is of what we’ve covered is:
    1. Arduino
    2. Processing
    3. Sensors (whatever we have in the lab, or you can add more of your own e.g from Radio Shack
    4. Actuators (LEDs or whatever else you want to use)
    5. Communication between Arduino and Processing
    6. if() statements, either in Arduino or in Processing
    7. for() loops, either in Arduino or in Processing
    8. You may add other things not listed here
  4. Your project does not have to be practical or meaningful as art, not does it need to be visually appealing. It is just a demonstration of techniques you’ve learned.
  5. The project must have some complexity but should not be overly complex; you have less than 2 weeks to finish it.
  6. If your project is a Processing  program only, it should include, and you must identify, at least  7 different concepts
  7. If your project includes an Arduino , it should include, and you must identify, at least  4 different concepts
  8. You are encouraged to talk to each other, share ideas, ask each other questions, and help each other, but each of you must make your own project.
  9. You may use examples and other projects from books, the internet, your friends, etc. for inspiration and you may copy portions, but most of the work should be your own.
  10. Some example projects might be:
    1. Using some concepts from the Pong example, a game where a paddle is used to move a ball around a simple maze. The paddle is moved using the mouse, and is rotated using a potentiometer attached to Arduino. The ball can be moved as slowly as you want – the purpose is not to create a challenging game but to demonstrate what you’ve learned.
    2. An Arduino has one red LED one green LED, a potentiometer, and a pushubtton.  When the button is pressed, The potentiometer controls the brightness of the red LED. When the button is not pressed, the potentiometer controls the brightness of the green LED.
    3. A potentiometer controls the color of an ellipse in Processing. Clicking the mouse in the Processing windows turns an LED on.
  11. Remember that most of your time will probably be spent trying to fix problems, so you want to get to that point as quickly as possible. Don’t spend too much time designing: come up with an idea quickly and start building and programming.
  12. Do not wait until the last moment to start. This will take much longer than you expect.
  13. Use your resources! I have office hours Monday and Wednesday, the Hybrid Lab often has people who can help, especially the lab manager Andrew, and we have the the programming coach Colin . You can also make appointments with Andrew, details are on the wall outside the Hybrid Lab.
  14. Questions? Please contact me.

Week 7 , Monday, March 3

  1. Project deadline:  Sunday, March 9, at 9am
  2. Discuss projects
  3. Work on projects
  4. Perhaps get to new material that we did not cover on February 24

Note that the midterm project has two components, one due on Sunday and one on Monday

Homework due Sunday, March 9, 9am
Your project documentation must be in my email box by 9am or it will be considered late and not accepted:

  1. Schematic
  2. Detailed explanation
  3. Program(s)
  4. At least one photograph (nothing fancy; cellphone is fine)
  5. Short video showing behavior (nothing fancy; cellphone is fine)

Homework due Week 7 , Monday, March 10

I will ask each of you to show me your projects briefly on Monday.

Week 7 , Monday, March 10

Briefly see everyone’s projects

Lecture:  Object Oriented Programming: Objects and Classes

  • Motivation: How to manage multiple things with different qualities and abilities
    • e.g. the balls in some of your projects
  • Objects Tutorial from Learning Processing by Daniel Shiffman
    • A cookie cutter makes cookies, but it is not a cookie itself. The cookie cutter is the class, the cookies are the objects.
  • Some examples

Homework due Week 8 , Monday, March 17

  1. Review the tutorial we did in class and the examples to understand how to write your own class and how to use it.
  2. Create a class that draws a line. You can call it Line.
    1. Your Line should have the following internal variables:
      1. startPosX, startPosY, endPosX, endPosY which describe the lines starting and ending positions
      2. c which will be the color of the line
        (hint: look at the tutorial we studied in class, near the end)
    2. Your line class should have the following methods:
      1. Line(startX, startY, endX, endY) is the constructor
      2. setColor(r, g, b)  which allows you to change the line color
        (hint: look at sketch_005 above)
      3. moveLeft() which moves the entire line to the left one pixel
        (hint: Look at sketch_004 above)
      4. moveUp() which moves the entire line to the up two pixels
        (hint: Look at sketch_004 above)
      5. displayLine() which displays the line
        Don’t worry about keeping the line within the window
    3. Demonstrate how to use your new Line class:
      1. Create a red line
      2. Create a blue line in a different place
      3. Create a green line in a different place
      4. Move the blue line to the left in each frame
      5. Move the green line up in each frame
  3. Remember to use your resources: me, Colin, each other.

Week 8 , Monday, March 17

Lecture

  • Arrays
    int[] foo; 
    
    void setup() {
    
      foo = new int[100];
    
      for (int index = 0; index < 100; index = index + 1)
      {
        foo[index] = 99;
      }
    
      for ( int index = 0; index < 100; index = index + 1)
      {
        println("foo number " + index + " is " + foo[index]);
      }
    }
  • Useful way to use for() loops with arrays
    float[] foo; 
    
    void setup() {
    
      foo = new float[100];
    
      for (int index = 0; index < 100; index = index + 1)
      {
        foo[index] = 99;
      }
    
      for (float thisfoo : foo)  
      {
        println(thisfoo);
      }
    }
  • Transformations
    • Translate()
      void setup()
      {
        size(200, 200);
        background(255);
        noStroke();
      
        // draw the original position in gray
        fill(192);
        rect(20, 20, 40, 40);
      
        // draw a translucent red rectangle by changing the coordinates
        fill(255, 0, 0, 128);
        rect(20 + 60, 20 + 80, 40, 40);
      
        // draw a translucent blue rectangle by translating the grid
        fill(0, 0, 255, 128);
        translate(60, 80);
        rect(20, 20, 40, 40);
      }
    • Rotate()
      void setup()
      {
        size(200, 200);
        background(255);
        noStroke();
      
        // draw the original position in gray
        fill(192);
        rect(20, 20, 40, 40);
      
        rotate(PI/4);
      
        // draw a translucent blue rectangle
        fill(0, 0, 255, 128);
        rect(0, 0, 40, 40);
      }
      void setup()
      {
        size(200, 200);
        background(255);
        noStroke();
      
        // draw the original position in gray
        fill(192);
        rect(20, 20, 40, 40);
      
        // move (0,0) to the new location ...
        translate(20,20);
        // ... and now rotate
        rotate(PI/4);
        fill(0, 0, 255, 128);
        rect(0, 0, 40, 40);
      }

      Prefer degrees to radians? use

      rotate(radians(45));
    • Undoing transformations
    • void setup()
      {
        size(200, 200);
        background(255);
        noStroke();
      
        // draw the original position in gray
        fill(192);
        rect(20, 20, 40, 40);
      
        // save current coordinate system
        pushMatrix();
        // move (0,0) to the new location ...
        translate(20,20);
      
        // save this new system (translated)
        pushMatrix();
        // ... and now rotate
        rotate(PI/4);
        fill(0, 0, 255, 128); // blue
        rect(0, 0, 40, 40);
      
        // undo the rotation
        popMatrix();
        fill(255, 0, 0, 128); // red
        rect(0, 0, 20, 20);
      
        // and undo the translation
        popMatrix();
        fill(0, 255, 0, 128); // green
        rect(0, 0, 20, 20);
      }
    • Tutorials
    • Justification
      • File -> Examples -> Basics -> Transform -> Arm
  • Review of any topics that are still confusing
    • Homework solutionWithout arrays:
      With arrays:
  • Combining homework with one of the transformations learned today
  • What new topics would you like to learn?
    • More Arduino: motors, more analog, more blinking lights
    • More Processing: intro to animation
    • Sound, both on Arduino and Processing (e.g. Evan’s midterm project)
    • I welcome further requests

I’ve created a shared Google drive for sharing your projects so that you may each learn from each other. Please request access to the folder and then create a folder of your name, and in that place your midterm project. Include schematic, sketches (Arduino and Processing), and your description. The folder is at https://drive.google.com/a/cca.edu/folderview?id=0B43590UC58A9dnkzaDFScFYzaEE&usp=sharing

Homework due Week 10 , Monday, March 31

Final Project: initial concept, identify blocks, identify process

  1. Conceive of your final project. If you don’t have anything in mind, research other programming and electronic projects for ideas. You might Google for keywords such as “Arduino”, “Processing”, “projects”, along with anything else you are interested in. You might want to start here.
  2. Final project requirements:
    1. Must be more complex than the midterm project
    2. Must use some of the advanced concepts learned recently, such as arrays, classes, and loops.
    3. Must require more new work and not consist mostly of exercises, examples, or homework
    4. Your project must use at least some software and some hardware. If you want to use software other than Processing or hardware other than Arduino contact me.
  3. Describe your project concept and how you intend to create it:
    1. Write a paragraph or two about what your project will do
    2. Draw a block diagram of the electronics. A block diagram is the high level view of the electronics, without getting into the details of the circuit. It helps you identify what electronics you will need to figure out, such as sensors and actuators. A block diagram consists of “blocks” (e.g. “transistor”, “light sensor”, “Arduino”, “rotation sensor”) with lines showing how the blocks will connect to each other.
    3. Describe in words or in blocks how your program will do what it needs to do.  Similar to the block diagram of the electronics, details aren’t needed. For instance, you could say “loop over the array of objects, setting each object to a different color”.
  4. List all the parts you think you will need to buy
  5. List all the parts you think you will need to make
  6. List anything you need to learn
  7. Identify the part of your project you are most unsure or most worried about, or that you think will give you the most difficulty.

Week 10 , Monday, March 31

Review homework

  • Review issues in prior homework due March 17 (classes
  • Review final projects:
    • Check for sufficient complexity
    • Check both making and buying parts lists
    • Check what needs to be learned
    • Assign next step

Lab

  • Make progress with your final project, either prototyping, researching, or talking to me

Homework due Week 11, Monday, April 7

  • I warned some of you that your projects lack sufficient technical content to earn full credit for a final project. I suggest you continue working on your original project, while thinking of ways to increase the technical content once the basic functionality is working. Examples of more technical content would include more sensors, actuators, or other components or more complex behavior requiring more complex programming. As always, you may bounce your ideas off me if you are unsure.
  • Continue working on your projects. Continue doing research and prototyping parts of your project. Start building and programming. Email me as often as you wish with questions. I will do my best to answer in a timely fashion. For next week, you must show tangible progress:
    • If your project involves electronics, create an accurate schematic. It can be hand drawn or done in Fritzing or other software. Send me the schematic.
    • If your project involves programming, start programming and send me what you have. It does not need to be fully functional yet but it must show that you’ve put some thought into what needs to happen. Use comments to describe the parts you have yet to figure out. Some of you with complex programming projects might just show me the classes. Again you don’t need the full code but perhaps just describe the variables and methods your objects might need, and start roughing out how you will use these properties to create your program.
    • If your project requires that you buy or make parts, start ordering parts now and start building the parts you need to build. If you have to make a complex assembly, you might start by sketching a pretty accurate diagram of how it needs to work, and start prototyping some parts in simple materials e.g. foam board etc. Take pictures and send these to me.
    • If your project requires research, do it. Ask me if you have trouble finding what you are looking for. Document what you’ve discovered. Send it to me.
  • I don’t require that you to have something finished or working (although if you do that’s great). I do require that you show progress.
  • If you don’t know what to do, ask me. If you have nothing to show next week because you didn’t know how to proceed and you didn’t ask me you will receive 0 for this homework assignment.
  • Upload your midterm project to the Google drive at https://drive.google.com/a/cca.edu/folderview?id=0B43590UC58A9dnkzaDFScFYzaEE&usp=sharing
  • As always, this assignment is due by 8:15am of our next meeting. Work received after 8:15am will not be accepted.

Week 11, Monday, April 7

  • Motors
    • Brushed DC motor, so-called “standard” or “regular” motor
      • Lab: Brushed DC motor, as shown here
    • Stepper motor (Arduino -> File -> Examples -> Stepper -> stepper_oneRevolution)
    • Servo motor (Arduino -> File -> Examples -> Servo -> Knob or Sweep)
    • Muscle wire
  • Sound
    • Tone (Arduino -> File -> Examples -> Digital -> ToneKeyboard)
    • Minim (Processing -> Examples -> Libraries -> PlayAFile)

Homework due Week 12, Monday, April 14

  1. This homework is to be handed in. Identify:
    1. What progress you made between April 7 and April 14
    2. What you have left to do, make, buy, learn, program, figure out, or decide
    3. What you hope to do in class at our next meeting (April 14)
    4. What additional material you need me to teach

Week 12, Monday, April 14

Lecture

More Arduino, more blinking lights, and a new concept: State Machines

Homework due Week 13, Monday, April 21

We have only 3 more work meetings (your projects will be due at our last meeting on May 5). Think about what you need to do each week for the next 3 weeks so that you can finish this project in 3 weeks to avoid competing with projects and assignments from your other classes.

  1. This homework is to be handed in, either by email or paper. Identify:
    1. What progress you made between April 14 and April 21
    2. What you have left to do, make, buy, learn, program, figure out, or decide
    3. What you hope to do in class at our next meeting (April 21)
    4. What additional material you need me to teach

Week 13, Monday, April 21

Lecture: Debugging!

  1. Software
    1. Make sure you understand what is going on
      1. Add println() to display values and to report on stage in processing e.g.:
        Serial.print("before loop, sensor value is ");
        Serial.println(sensorValue);
        for (int i = 200, i > 0, i--)
        {
        Serial.print("inside loop, i is ");
        Serial.println(i);
        // other stuff happens
        }
        Serial.print("after loop, sensor value is ");
        Serial.println(sensorValue);
      2. No serial monitor? Use LEDs to indicate what’s going on e.g.:
        digitalWrite(redLED, HIGH) //before loop
        digitalWrite(greenLED, LOW) //not in loop
        digitalWrite(yellowLED, LOW) //not after loop
        delay(50); // just enough to see
        for (int i = 200, i > 0, i--)
        {
        digitalWrite(redLED, LOW) //not before loop
        digitalWrite(greenLED, HIGH) // in loop
        digitalWrite(yellowLED, LOW) //not after loop
        delay(50); // just enough to see
        // other stuff happens
        }
        digitalWrite(redLED, LOW) //not before loop
        digitalWrite(greenLED, LOW) // not in loop
        digitalWrite(yellowLED, HIGH) // after loop
        delay(50); // just enough to see
      3. Problems with libraries
        1. Ideally, confirm the library works with the examples that came with it or came from the website where you got the library. finally try to find examples that seem to be reliable (comments are a good way to determine)
        2. be careful of libraries that are very old, especially if the comments are also very old. it might be that changes in arduino prevent them from working now.
        3. Join any mailing lists or forums related to the library or the website that the library came from. search the archive for hints, and then post your question after you’ve done some research
    2. Isolating problems
      1. Create a small test program to isolate the part that is not working
        1. This makes it easier to work on
        2. Identify whether it’s due to an interaction with something else
        3. Much more likely to get help quickly from teacher or others (online forum, etc.
  2. Hardware
    1. Swapping parts
    2. Isolating problems
        1. Create a small test circuit to isolate the part that is not working
        2. This makes it easier to work on
        3. Identify whether it’s due to an interaction with something else
        4. Much more likely to get help quickly from teacher or others (online forum, etc.
    3. Test equipment
      1. Oscilloscope
      2. Multimeter
      3. Variable power supplies
  3. Online resources
    1. Copy and paste the error message into Google
    2. Google keywords: Arduino and/or Processing, along with what you are trying to do or any components that are part of the issue. The goal of the project is usually not a good keyword.
    3. Posting a question on a forum, mailing lists, etc.
      1. Before posting, you must prepare
        1. Do everything else possible first. People are much more helpful when it’s obvious that you’ve done your homework e.g. researching the issue, isolating the problem to a minimal circuit/program, getting local help (me, other teachers or students)
        2. Read some other posts in this forum/mailing list to get a sense of the culture. You want to post your question in a similar way
        3. Most forums have a post that suggests the best way to get help. This might be called something like “Before you Post” or “Read this First” or “How to Post”. Make sure you follow the instructions.
        4. Compose your post carefully. Include all the necessary information, but don’t confuse the issue with unnecessary information (e.g. the concept of your project probably doesn’t matter if you are getting an error from a library). Include your minimal circuit schematic or program, which must be neat and clear and well documented
        5. You are welcome to run the post by me first
        6. If it’s extremely late at night use sites in different time zones. Evening is probably the most appropriate time.
        7. Suggested sites
          1. Always start with the home site of any library or part that is key to what the problem is (assuming there is one). If your project is based on an Instructable or other set of instructions, post on that site if possible
          2. Arduino forum
          3. Adafruit forum
          4. Stack Exchange
          5. Spark Fun
          6. Tronixstuff
  4. How to reduce risks before buying components, using libraries, or trusting an Instructable or other instruction, example, or tutorial:
    1. Read the documentation. Is it clear and complete? Does it explain everything you need to know?
    2. Read all the comments and feedback to see if there are any issues and to gauge how helpful the provider is.
    3. Are examples and tutorials provided? Are they clear and complete? That’s a sign of reduced risk. Read those, and any comments on them.
    4. Google the name of the item. Is it discussed much? If there is no discussion that implies that no one else is using it. High risk. Follow some of the discussions. Do people seem to be having success and getting projects to work? Good, that indicates a low risk. If the discussions are mostly about problems that aren’t solved, that’s a high risk.

Homework due Week 14, Monday, April 28

  1. Complete the online course evaluation before class
  2. I want to see the basic functionality of your project working. In order to do this you might have to cut some corners. You will have to decide what is the bare minimum necessary in order to consider your project working, and leave all the rest for the last week. These might include:
    1. Extra features
    2. Nice presentation (e.g. box or construction)
    3. Custom graphics
    4. Custom sounds
  3. In addition to demonstrating your project, you need to document your project, which will be due, along with the final project, on May 5.
  4. If you need help, in addition to Colin, you can also make appointments with Andrew, and you can often catch him informally in the lab. If he isn’t available, don’t be afraid to ask the lab monitor or other students in the lab. I will be somewhat available this Wednesday between 9 and noon, in the lab.

Final projects due !!
Week 15, Monday, May 5

Deadlines

  • Course evaluations Monday May 5 at 8:30 AM
  • Final project demonstrations on Monday May 5 at 9 AM
  • Documentation due on Friday May 9 at 11:59 PM

Schedule for May 5 project demonstrations

  • 8 AM – 9 AM: Installation and completing course evaluations, if you have not already done so
  • 9 AM: Project reviews
  • After reviews
    • Interface show
    • CSU Summer Arts Program 2014: Inventor’s Workshop
    • Class feedback

Required documentation

  • Project description
  • One or more photographs
  • Short video (nothing elaborate – cellphone is fine)
  • Description of any difficulties or complications that you experienced while using any libraries or parts, along with how you solved the problems
  • Clear, complete, and correct schematic (if there is any hardware). May be hand-drawn or any CAD. Extra points for using Fritzing and providing the .fzz file.
  • Clear, complete, and well documented sketches (Arduino/Processing as necessary)
  • Complete and correct parts list of all electronic modules or components, with links to any unusual items (as necessary)
  • Links to any necessary libraries (as necessary)
  • List of resources you used (books, websites, tutorials, etc.)
  • This document and all supporting files must be placed in our class Google folder, in your folder (which is named your name), in a new subfolder named “final”.  Documents in the wrong place will lose points.
  • Points will be removed for incomplete, incorrect, and unclear documentation

End of Semester Show

  1. I encourage you to display your project at the bi-annual end of semester Interface Show (Art using Technology using Art) at the Oliver Art Center in Oakland, Friday, May 9, between 7-10PM. This is a popular show not just for the CCA community but for many Bay Area artists, designers, and conceptual thinkers.
    Setup will be all day on Friday between 10 AM and 6 PM, and all projects must be removed at the end of the evening. While no registration is required, email to Donald Day would be appreciated so that he can coordinate positioning. Otherwise, just show up Friday before 6 PM. Questions? Ask me or Donald Day. UPDATE: If  you need any Media Center support such as projectors or laptops, make the request by contacting Maggie or Jess or directly, or by asking Don to coordinate on your behalfposter_spr14_medWhether you show or not, you are encouraged to attend and also spread the word by telling your friends and displaying this poster where you can.

Resources

  • If you want more LEDs than you have pins, you can do this by wiring up the LEDs in a matrix. The LEDs can be connected directly to the Arduino pins (which limits the number of LEDs you can have) or through an IC such as a shift register which can be extended indefinately. Using a matrix requires slightly more complex software.
    • This Instructable has excellent instructions on how to create the matrix of the LEDs. It uses shift registers.
    • Another Instructable using shift registers has an excellent explanation of how the matrix control works and how the shift register works.
    • In this tutorial from the Arduino website the LEDs rows and columns are connected directly to Arduino pins with no shift registers. The software includes an interrupt handler to automate refreshing the display. Note that it’s quite old and since it depends on a library it may no longer work.
  • Introduction to Arduino video
  • Extra resources on the solderless breadboard are here, here, and here. Let me know if you find these helpful or not
  • Excellent introduction to Arduino: Arduino in a Nutshell
  • Adafruit’s Arduino lessons
  • Arduino tutorials on Tronixstuff.com
  • Jeremy Blum’s excellent series of Arduino video tutorials. Scroll down past the first few posts to get to Tutorial 15. Click on “Previous Posts to see earlier tutorials, or go directly to tutorial 1.
  • Traer Physics library for Processing, and a great example
  • Examples from Daniel Shiffman’s Learning Processing book
  • Various links for working with Arduino projects
  • Hybrid lab hours, including Spring Break hours
  • Hybrid Lab Facebook page, also showing Spring Break hours

Possible future topics

  • Arduino: more analog, physics
  • Processing: intro to animation
  • Do we need to talk about high current devices? is anyone using any?
  • Processing -> File -> Examples -> Basics -> Transform -> Arm
    • Review how transforms work and
    • You can imagine how to replace mouse with Arduino and potentiometer, much like Arduino -> File -> Examples -> Communication -> SerialCallResponseASCII
    • What about the other way around, i.e. using mouse to control something that moves?
      • Arduino -> File -> Examples -> Communication -> ReadASCIIString but instead of RGB LED, servo motor
  • Processing Arm controls Arduino Servo. Arduino code:
    Processing code:

 

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 *