Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fabricademy: Wearables and E-Textiles II

Becky Stewart
November 23, 2017

Fabricademy: Wearables and E-Textiles II

Becky Stewart

November 23, 2017
Tweet

More Decks by Becky Stewart

Other Decks in Technology

Transcript

  1. 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.
  2. 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
  3. 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)
  4. 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
  5. 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.
  6. 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.
  7. 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.
  8. 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 }
  9. • 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
  10. Vin Vout 5V GND GND R1 R2 Something between 5V

    and GND Analog Sensor Circuits
  11. Vin Vout 5V GND GND R1 R2 Something between 5V

    and GND Analog Sensor Circuits
  12. Vin Vout 5V GND GND R1 R2 Something between 5V

    and GND = Vout Vin x R1 + R2 R2 Analog Sensor Circuits
  13. Vin Vout GND R1 R2 potentiometer *In this circuit, both

    R1 and R2 are changing when the knob is turned. Analog Sensor Circuits
  14. 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
  15. // 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); }
  16. 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.
  17. Actuator Circuits Use a circuit that passes the current through

    something else besides the microcontroller.
  18. Actuator Circuits • PWM is not really an analog signal.

    • If your actuator isn’t working when using analogWrite(), see if it works with digitalWrite().
  19. // 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); }
  20. 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.
  21. 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
  22. Hard-Soft Connections Kobakant’s How to Get What You Want is

    always an excellent resource http://www.kobakant.at/DIY/? cat=32
  23. Hard-Soft Connections eTextile Summer School Workshop by Hannah Perner-Wilson and

    Irene Posch http://etextile- summercamp.org/2017/ summerof/pcbattiny-workshop- schedule/
  24. Hard-Soft Connections • When in doubt, use a snap. •

    Solderable and sewable. http://www.geeetech.com/wiki/index.php/LilyPad_Arduino_SimpleSnap
  25. 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.
  26. 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.