Each Group Collect
- Digital Multimeter
- Variable Voltage Power Supply
- Bana Plug Leads
- Resistors
- DC Motor
What is Electricity?
A general understanding of electricity and the rules that determine how it flows and how it can be controlled are crucial to quickly prototyping your designs. These resources cover the fundamentals of working with electricity.
- Tom Igoe: Understanding Electricity
- Sparkfun: Voltage, Current, Resistance and Ohm’s Law
- ITP: Electricity, the Basics
- Voltage is the difference in charge between two points.
- Current is the rate at which charge is flowing.
- Resistance is a material’s tendency to resist the flow of charge (current).
Water analogy from Sparkfun
Voltage = Pressure in system
Current (Amperage) = Amount of Flow
Resistance = Resistance to Flow
V = I * R (voltage = current * resistance)
I = V / R (current = voltage / resistance)
Solve for LED / Resistor Combo
We know the ideal forward voltage (Vf) and current (I) of the LED.
Target Vf = 3.3v
Target I = 20mA (0.02A)
V = I * R
R = (Vs – Vf) / I
Exercise 1: Learn the Digital Multimeter (DMM)
Sparkfun: How to Use a Multimeter
- Set up a simple circuit on a breadboard with an LED, a resistor, and the variable voltage power supply:
- Set the power supply to 5V
- Use the the DMM to measure voltage at different points of the circuit
- Notice the amount of current being used by the power supply
- Insert the DMM into the circuit and measure the amount of current (see if it matches what the power supply says)
- What happens if you change the resistor?
- Add a switch or button
- Draw the [circuit diagram](https://learn.sparkfun.com/tutorials/how-to-read-a-schematic) on the table
What is Arduino?
A simple microcontroller and software combo developed to help designers, artists and non-engineers rapidly prototype with electronics.
Some things to remember:
- Analog Pins are for reading only (0v – 5v)
analogRead(pinNumber)
returns an integer value between 0 – 1023- Digital Pins can be
INPUT
orOUTPUT
- digital pins can supply a low-current (100mA) 5v supply in output mode:
digitalWrite(pin, HIGH/LOW);
- digital pins can read the state of that pin, as either
HIGH
orLOW
(5v or 0v):digitalRead(pin);
- digital pins can supply a low-current (100mA) 5v supply in output mode:
- You can run the arduino WITHOUT the USB cable attached (only a 5v-24v barrel jack)
- You can also power from the Vin and GND pins.
Exercise 2: Set up Arduino & Blink
- Download the Arduino IDE
- Follow the Getting Started guide for the Arduino UNO (word for word!)
- Run the Blink! example sketch
- Open Examples > Basics > Blink
- Plug your Arduino into the computer
- Choose your board: Tools>Board
- Choose the correct port: Tools>Port
- Click the check icon (verify)
- If no errors, upload to the arduino
Exercise 3: Reading Data & Graphing it
- Upload the Standard Firmata to your Arduino (check out File>Examples>Firmata>StandardFirmata)
- Make sure you have the Arduino(Firmata) library (you can download this from the Sketch>Import Library>Add Library… menu)
- In Processing and copy/paste this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
/* arduino_input Demonstrates the reading of digital and analog pins of an Arduino board running the StandardFirmata firmware. To use: * Using the Arduino software, upload the StandardFirmata example (located in Examples > Firmata > StandardFirmata) to your Arduino board. * Run this sketch and look at the list of serial ports printed in the message area below. Note the index of the port corresponding to your Arduino board (the numbering starts at 0). (Unless your Arduino board happens to be at index 0 in the list, the sketch probably won't work. Stop it and proceed with the instructions.) * Modify the "arduino = new Arduino(...)" line below, changing the number in Arduino.list()[0] to the number corresponding to the serial port of your Arduino board. Alternatively, you can replace Arduino.list()[0] with the name of the serial port, in double quotes, e.g. "COM5" on Windows or "/dev/tty.usbmodem621" on Mac. * Run this sketch. The squares show the values of the digital inputs (HIGH pins are filled, LOW pins are not). The circles show the values of the analog inputs (the bigger the circle, the higher the reading on the corresponding analog input pin). The pins are laid out as if the Arduino were held with the logo upright (i.e. pin 13 is at the upper left). Note that the readings from unconnected pins will fluctuate randomly. For more information, see: http://playground.arduino.cc/Interfacing/Processing */ import processing.serial.*; import cc.arduino.*; Arduino arduino; int potPin = 0; int LEDPin = 6; void setup() { size(470, 280); // Prints out the available serial ports. println(Arduino.list()); // Modify this line, by changing the "0" to the index of the serial // port corresponding to your Arduino board (as it appears in the list // printed by the line above). arduino = new Arduino(this, Arduino.list()[0], 57600); // Alternatively, use the name of the serial port corresponding to your // Arduino (in double-quotes), as in the following line. //arduino = new Arduino(this, "/dev/tty.usbmodem621", 57600); arduino.pinMode(LEDPin, Arduino.OUTPUT); } void draw() { background(0); stroke(255); // Draw a filled box for each digital pin that's HIGH (5 volts int potVal = arduino.analogRead(potPin); //map the values from 0-1023 to 0-255 int mappedVal = (int)map(potVal, 0, 1023, 0, 255); arduino.analogWrite(LEDPin, mappedVal); // Draw a circle whose size corresponds to the value of an analog input. noFill(); int circleDiameter = arduino.analogRead(potPin) / 16; ellipse(width/2, height/2, circleDiameter, circleDiameter); } |
- Find a sensor (Potentiometers are a good one)
- Attach it to the Analog pins of your Arduino (You may need to find a diagram/datasheet/instructions on the internet)
- Run the Processing sketch!