Your browser does not support the canvas tag.

Week 3
Maker Faire ! Presentation



Every game class talks about the Magic Circle or the "consecrated spot" but no class anywhere has a better example than the ULTIMATE HOCKEY FIGHT!

This is some serious game

simple and potentially attainable games.
Cursor 10
Planarity (BE CAREFUL)
Simmer Down Sprinter
4 Minutes and 33 Seconds of Uniqueness
1st person Tetris
Lightbot One of my favorite teaching games.

The Game.


Electric component symbols

componenets
Important Terms

Ohm's Law

Ohms Law: I = V/R

An LED will only work in one direction. The short leg (cathode) goes towards the ground and the long leg (anode) towards the positive. What if the legs are the same size? On many LEDs the cathode has a flat side, but it won't hurt to put it in backwards and flip it if it doesn't light up.
The resistor can go in either way round.

Helloworldled
This circuit includes a switch. The switch could go anywhere in the circuit and it would still server to turn the light on an off. Switched are either "toggle" or "momentary" - a momentary switch usually has a spring in it to push it back into position. Momentary switches are either N.O. (normally open) or N.C. (normally closed>.

If course all a switch does is open of close the connection, so you can make a switch out of anything that does this.
Helloworldled
This circuit includes a switch and a Capacitor. There are two common types of "cap" electrochemical Capacitors, or Ceramic. The Electrochemical Capacitors that we are using are larger than the ceramic ones, and look like little silos.
The capacitor will build up a charge. when you turn the switch off you can see the cap dissipate in the LED - even though the power it no longer on! It's Magic! Try a larger or smaller cap.


Series and Parallel
If something is in series it means that it is in the same chain. So if LED's are in series removing 1 led will turn them all off. If the LEDs are in parallel, you can remove one without turning them all off. If you put then in series, use the same calculation as above to calculate the resistor, only add together the voltage of the LED's.

Series

Parallel

With LEDs, the better way to have then in parallel is to give each LED its own resistor.

Betterparallel

Okay, now try using a photocell instead of the pot in our analog circuit! A photocell is a light sensitive variable resistor. Here's the wiring diagram. You can do it! Notice how similar this is to the button diagram - big difference being the signal goes to the analog port instead of digital. You can use the same code from above, but notice that the photocell gives you a much narrower range than the pot does.




Analog Out

So far we have used the digitalRead on a digital port, digitalWrite in on a digital port and analogRead on an analog port so guess what port we use for analogWrite?
WRONG! analogWrite actually uses the digial ports that have PWM (or "~") printed next to them. PWM stand for Pulse Width Modulation, mostly they are used to control Servos, however, you can also use PWM to change the brightness of an LED.
Another complication with analogWrite, is that it does not work very well with the standardFirmata that you currently have installed on the arduino. Upload the Simple analogFirmata to the Arduino before using the below sketch in processing.
Set up your arduino and breadboard with an LED in digital port 9. Use a resistor (220 ohm or so) to limit the voltage going to the led. (Don't forget that ports other than 13 need a resistor if you are pluggin in an LED.

import processing.serial.*; // accesses the serial library
import cc.arduino.*; // accesses the arduino library
Arduino arduino; // creates a variable called arduino
int ledPin = 9; // a variable for the pin on the arduino
int counter = 0; // a variable for timing; 
boolean dir = true; // a variable that is either true or false

void setup() {
  //println(Arduino.list()); // scans the USB port
  arduino = new Arduino(this, Arduino.list()[0], 57600); // sets our variable "arduino" to the actual, arduino
  arduino.pinMode(ledPin, Arduino.OUTPUT);// sets port 13 to output
}
void draw() {
  if (dir == true){
  counter ++; // adds 1 to the varaible counter with each loop
  }
  else{
    counter --;
  }
  arduino.analogWrite(ledPin, counter);

  if (counter >= 100 || counter <= 0) {
   dir = !dir; 
  }
  println (counter); 
}
This wwek's reading is from Olia Lialina.