Share
Embed
Fabricademy: Wearables and E-Textiles II
See http://wiki.textile-academy.org/fabricademy2017/classes/wearables2 for the class notes.
Becky Stewart
November 23, 2017
Transcript
64 slides
-
mini-assignment: choose an object • Look at interactive objects around
you/online and think of them as systems. • What are the inputs; what are the outputs? • Are the inputs and outputs digital (only on-off) or variable (have a range of values between fully on and fully off). • This is easier to consider for inputs, don’t worry about the details of outputs right now. -
assignment • Make an interactive object. Build off the tools
and methods you have used so far. -
Prep for Thursday • Prepare a pressure or stretch sensor
• Install Arduino, go through Blink sketch • Doesn’t matter whether an Uno, Lilypad or other Arduino board • Have a multimeter handy -
Physical Computing • A computational device can turn a voltage
into a number and can turn a number into a voltage. • The code running on the device decides what happens to those numbers and how they are created. computer sensor sensor sensor actuator actuator actuator Digital: 0V or 5V —> 0 or 1 Analog: 0V to 5V —> 0 to 1023 Digital: 0 or 1 —> 0V or 5V Analog: 0 to 255 —> 0V to 5V (this is an oversimplification) -
Physical Computing • A computational device is necessary to do
things like • make complex mappings from inputs to outputs • connect to another device with a wired connection like serial or I2C • make a wireless connection like wifi or Bluetooth -
Microcontrollers • Runs only one piece of code. • Doesn’t
use an operating system to manage a bunch of programs. • Quick to start and easy to shut down (add power, take away power). • Usually much more limited than a full computer. -
Single-Board Computers • Needs an operating system to work —
usually uses a Linux system. • Can handle multiple programs at the same time. • Takes longer to start up, and can be easy to corrupt data if you don’t follow proper shutdown procedures. -
Digital Sensor Circuits • Digital sensors (usually thought of as
switches) are cheap. • No calibration. • When connected to a microcontroller, need to use a pull-up or pull-down resistor. -
int switchPin = 7; void setup() { pinMode( switchPin); Serial.begin(
9600 ); } void loop() { int switchValue; switchValue = digitalRead( switchPin ); Serial.println( switchValue ); delay( 300 ); // slow down to make it easier to read } -
• Arduinos can only watch changes in voltage. • Not
changes in resistance or current. • But we can turn a changing current or resistance into a changing voltage by being clever. • Use a circuit called a voltage divider. Analog Sensor Circuits -
Vin Vout 5V GND GND R1 R2 Something between 5V
and GND Analog Sensor Circuits -
Vin Vout 5V GND GND R1 R2 Something between 5V
and GND Analog Sensor Circuits -
Vin Vout 5V GND GND R1 R2 Something between 5V
and GND = Vout Vin x R1 + R2 R2 Analog Sensor Circuits -
Analog Sensor Circuits = Vout Vin x R1 + R2
R2 Vin Vout GND GND R1 R2 -
Vin Vout GND R1 R2 potentiometer *In this circuit, both
R1 and R2 are changing when the knob is turned. Analog Sensor Circuits -
1. Does the object change resistance when you interact with
it? Check with a multimeter. 2. If does, create a voltage divider. Decide if you want the object to be R1 or R2. 3. Choose a static resistor that gives you the values you are looking for. Generally you want a value that is halfway between the min and max resistances of your sensor. Analog Sensor Circuits -
// to the pins used: const int analogInPin = A0;
// Analog input pin that the potentiometer is attached const int analogOutPin = 9; // Analog output pin that the LED is attached to int sensorValue = 0; // value read from the pot int outputValue = 0; // value output to the PWM (analog out) void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: analogWrite(analogOutPin, outputValue); // print the results to the serial monitor: Serial.print("sensor = "); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue); // wait 2 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(2); } -
Actuator Circuits • The main consideration for actuators is how
much current they need (how much they draw). • An actuator that needs too much current can harm your microcontroller. • Motors and a lot of LEDs will probably need more than your board can supply. -
Actuator Circuits Use a circuit that passes the current through
something else besides the microcontroller. -
Actuator Circuits • PWM is not really an analog signal.
• If your actuator isn’t working when using analogWrite(), see if it works with digitalWrite(). -
// to the pins used: const int analogInPin = A0;
// Analog input pin that the potentiometer is attached const int analogOutPin = 9; // Analog output pin that the LED is attached to int sensorValue = 0; // value read from the pot int outputValue = 0; // value output to the PWM (analog out) void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: analogWrite(analogOutPin, outputValue); // print the results to the serial monitor: Serial.print("sensor = "); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue); // wait 2 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(2); } -
Hard-Soft Connections • E-textiles currently always combine hard (PCB, LEDs,
etc) components with soft (conductive threads and fabrics). • When adding in a microcontroller, always have to deal with these connections. -
Hard-Soft Connections • One of my current works- in-progress •
Bela is the single-board computer • Sits on a 2-layer fabric circuit board (FCB) • Hard-soft connection is stripped wire sewn onto conductive fabric pads -
Hard-Soft Connections 3.3V GND A0 A2 A3 A4 A1 D0
D1 Ground 3.3V and inputs -
Hard-Soft Connections Kobakant’s How to Get What You Want is
always an excellent resource http://www.kobakant.at/DIY/? cat=32 -
Hard-Soft Connections eTextile Summer School Workshop by Hannah Perner-Wilson and
Irene Posch http://etextile- summercamp.org/2017/ summerof/pcbattiny-workshop- schedule/ -
Hard-Soft Connections • When in doubt, use a snap. •
Solderable and sewable. http://www.geeetech.com/wiki/index.php/LilyPad_Arduino_SimpleSnap -
Arduino Code • You learn to write by leaning to
read — the same is true with code. • Start by reading and reusing code that is already written, then you will build up the experience to write your own sketches. • The example sketches that come with Arduino cover almost every basic interaction you’ll want. -
Assignment • Make an interactive object. Build off the tools
and methods you have used so far. • If you are new to Arduino, just use one of the example sketches. • If you have a little Arduino experience, modify one of the examples. • If you are very experienced with Arduino, fully integrate the board into your project using hard-soft connections.