Class Notes, 14 Nov

Class Notes, 14 Nov

Appropriating technology for form, retaining functionality

Dazzle” was invented in WWI to protect ships from being seen by observers

Automobile designers have used it to protect/hide the shapes of new cars while they are tested on public streets.  Dazzle also prevents digital cameras with auto focus (like your mobile) from focusing on the car.

Now, dazzle is used to modify makeup and hair styles to protect individuals from facial recognition by systems using machine learning/AI software.

Applying one field’s form to another field

In the early days of music video and MTV, many videos were awful.  Video equipment was expensive and out of the budget of bands, but you have a friend who can “borrow” some equipment over the weekend…

The Toy Dolls, “Ellie the Elephant” (which is a classic punk/skater track)

Or you shoot your band playing live in a garage(?) then mix it with footage from movies, Dead Kennedys’ “Holiday in Cambodia

Or you hire an up-and-coming filmmaker and let them do what they do, make a movie, not a “music video”.

Jonathan Demme:  New Order, “The Perfect Kiss“, shown in movie theaters after trailers and before his Talking Heads Movie, “Stop Making Sense“.

Other movies made about music worth watching, Laurie Anderson, “Home of the Brave” and Tom Waits, “Big Time“.

 

 

 

Class Notes, 7 Nov

Not shown in class, a guide to making mechanical automata.  I think many of these could be made on a laser cutter or 3d printed.

507 Mechanical Movements.

Multiplexers, shift registers, and how to read a data sheet

The Arduino Playground guide the 4051, including the spiffy Arduino bitRead() call.

Instructables page on how to use the 74HC595 shift register.

The Sparkfun guide to reading a data sheet.

An interactive toy that passes “the tigoe test”

Paro, an interactive therapeutic robotic toy, now used in treatment for a variety of mental health problems.

Class Notes, 5 Oct 2017

Experiment with the pins on your h-bridge chip.  If you change directions, first bring the motor to a stop with

digitalWrite(enablePin, HIGH);

or the A1 and A2 combination that lets your motor glide to a stop.

// -*-c++-*-
/*
The MIT License (MIT)

Copyright (c) 2017 J. Eric Townsend

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/


const int enablePin = 11;
const int A1Pin = 10;
const int A2Pin = 9;
const int powerPin = 3;
const int switchPin = 7;
const int potPin = 0;

int bridgeState = 0;
boolean switchOpen = true;

void setup()
{
pinMode(A1Pin, OUTPUT);
pinMode(A2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(powerPin, OUTPUT);

pinMode(switchPin, INPUT);
pinMode(potPin, INPUT);

Serial.begin(115200);

}

void loop()
{

int speed = analogRead(potPin) / 4;

if (digitalRead(switchPin)) {
if (switchOpen) {
switchOpen = false;
digitalWrite(enablePin, LOW);
bridgeState += 1;
if (bridgeState > 3) {
bridgeState = 0;
}
}
}
else {
switchOpen = true;
}

Serial.println(bridgeState);
switch (bridgeState) {
case 0:
digitalWrite(A1Pin, LOW);
digitalWrite(A2Pin, LOW);
break;
case 1:
digitalWrite(A1Pin, LOW);
digitalWrite(A2Pin, HIGH);
break;
case 2:
digitalWrite(A1Pin, HIGH);
digitalWrite(A2Pin, LOW);
break;
case 3:
digitalWrite(A1Pin, HIGH);
digitalWrite(A2Pin, HIGH);
break;
}

digitalWrite(enablePin, HIGH);
analogWrite(powerPin, speed);
}

08 – class notes, 21 Sep 2017 — Intro to Power and Motors

Timing

Two short sketches showing how we can use the timing commands to blink and LED on and off without using delay() statements.

This is the version suggested in class:

// -*-c++-*-
/*
The MIT License (MIT)

Copyright (c) 2017 J. Eric Townsend

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/


/*
* This is a simple example that turns the LED on and off based on a single time.
*/


int debugLed = 13;
int blinkTime = 500;

bool ledState = LOW;
int now = 0;
int previous = 0;

void setup() {
// put your setup code here, to run once:
pinMode(debugLed, OUTPUT);
Serial.begin(115200);
}

void loop() {
now = millis();

if ((now - previous) > blinkTime) {
ledState = !ledState;
digitalWrite(debugLed, ledState);
previous = now;
}

}

You could also use if/else

// -*-c++-*-
/*
The MIT License (MIT)

Copyright (c) 2017 J. Eric Townsend

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/


/*
* This is a simple state machine that tracks the state of the LED and
* allows it to be on and off for different lengths of time.
*/


int debugLed = 13;
int blinkTimeOn = 1000;
int blinkTimeOff = 1000;

int ledOn = 1;
int ledOff = 2;

bool ledState = LOW;
int now = 0;
int lastOn = 0;
int lastOff = 0;

void setup() {
// put your setup code here, to run once:
pinMode(debugLed, OUTPUT);
Serial.begin(115200);
}

void loop() {
now = millis();

if (!ledState && ((now - lastOff) > blinkTimeOff)) {
ledState = HIGH;
lastOn = now;
} else if (ledState && ((now - lastOn) > blinkTimeOn)) {
ledState = LOW;
lastOff = now;
}

digitalWrite(debugLed, ledState);
}

Driving Actuators

Motors, solenoids, and servos require different methods of control and often require external sources of power.

Here’s a solenoid-example with a Fritzing doc showing the schematic.  There’s a similar method for using a motor that we will go over on Tuesday.

The basics of using a servo that we looked at in class.

07 – class notes, 19 Sep 2017 — Crits and Assignments

07 – class notes, 19 Sep 2017 — Crits and Assignments

Assignment Submissions

In your Arduino sketch be sure to put your name, the assignment, and the date in comments in the start of the sketch.

If you cut-and-pasted something from another person’s sketch, give them credit!

Critiques

Starting with the next assignment we’ll try and have an informal crit of a few projects and do a more practiced version of tonight’s demo.

A guide for professional graphic designers and students that I think applies to our class.

This is from a class taught by Bruce Sterling:

06 – class notes, 14 Sep 2017 — State Machines II

06 – class notes, 14 Sep 2017 — State Machines II

Switch/Case Statements

Switch/Case statements are useful for implementing state machines. There are two good exercises on the arduino site, Tutorial1 lays out a simple example and Tutorial2 shows how to use the “default:” case as “turn everything off”.

Here’s class responses for a “make a state machine” assignment I taught in the first Making Things Interactive, there are good examples of switch/case statements in these submissions.

for() Loops

for() loops are a way to iterate through a range of values and take an action on each iteration.  In my example (below) I use for() loops to pulse a light on and off.  In the arduino tutorial they use it for a “Knight Rider” effect of cycling through LEDs.

// -*-c++-*-
/*
  The MIT License (MIT)

  Copyright (c) 2017 J. Eric Townsend

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
*/



const int onOffPin = 2;
const int switch1Pin = 7;
const int switch2Pin = 8;

const int yellowLEDPin = 3;
const int redLEDPin = 5;
const int blueLEDPin = 6;

const int redOn = 1;
const int redOff = 0;
int redStatus = redOff;

const int blueOn = 1;
const int blueOff = 0;
int blueStatus = blueOff;

const int yellowOn = 1;
const int yellowOff = 0;
int yellowStatus = yellowOff;

const int noLED = 0;
const int redLED = 1;
const int blueLED = 2;
const int yellowLED = 3;

int activeLED = noLED;
int activeLEDPin = 0;

const int maxPWM = 255;
const int lowPWM = 0;

int pushCount = 0;

int currentPWM = 0;

void setup() {

  Serial.begin(115200);
  pinMode (onOffPin, INPUT);
  pinMode (switch1Pin, INPUT);
  pinMode (switch2Pin, INPUT);

  pinMode(yellowLEDPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(blueLEDPin, OUTPUT);
}

void loop() {

  if (digitalRead(switch1Pin) == HIGH) {
    activeLED++;
    if (activeLED > yellowLED) {
      activeLED = noLED;
    }
  }
  if (digitalRead(onOffPin) == HIGH) {
    //    if (redStatus || blueStatus || yellowStatus) {
    if (activeLED != noLED)  {
      switch (activeLED) {
        case redLED:
          activeLEDPin = redLEDPin;
          break;
        case blueLED:
          activeLEDPin = blueLEDPin;
          break;
        case yellowLED:
          activeLEDPin = yellowLEDPin;
          break;
        default:
          Serial.println("WARNING");
          // if nothing else matches, do the default
          // default is optional
          break;
      }
      analogWrite(yellowLEDPin, lowPWM);
      analogWrite(blueLEDPin, lowPWM);
      analogWrite(redLEDPin, lowPWM);

      for (int v = lowPWM; v < maxPWM; v++) {
        delay(10);
        analogWrite(activeLEDPin, v);
        //          analogWrite(yellowLEDPin, v);
        //          analogWrite(blueLEDPin, v);
        //          analogWrite(redLEDPin, v);
      }

    }
  }
  else   {
    //
    //    for (int v = maxPWM; v > lowPWM; v--) {
    //      delay(10);
    //      analogWrite(yellowLEDPin, v);
    //      analogWrite(blueLEDPin, v);
    //      analogWrite(redLEDPin, v);
    //    }
    activeLED == noLED;
    analogWrite(yellowLEDPin, lowPWM);
    analogWrite(blueLEDPin, lowPWM);
    analogWrite(redLEDPin, lowPWM);
  }

}
// -*-c++-*-
/*
  The MIT License (MIT)

  Copyright (c) 2017 J. Eric Townsend

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
*/



const int onOffPin = 2;
const int switch1Pin = 7;
const int switch2Pin = 8;

const int yellowLEDPin = 3;
const int redLEDPin = 5;
const int blueLEDPin = 6;

const int redOn = 1;
const int redOff = 0;
int redStatus = redOff;

const int blueOn = 1;
const int blueOff = 0;
int blueStatus = blueOff;

const int yellowOn = 1;
const int yellowOff = 0;
int yellowStatus = yellowOff;

const int noLED = 0;
const int redLED = 1;
const int blueLED = 2;
const int yellowLED = 3;

int activeLED = noLED;
int activeLEDPin = 0;

const int maxPWM = 255;
const int lowPWM = 0;

int pushCount = 0;

int currentPWM = 0;

void setup() {

  Serial.begin(115200);
  pinMode (onOffPin, INPUT);
  pinMode (switch1Pin, INPUT);
  pinMode (switch2Pin, INPUT);

  pinMode(yellowLEDPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(blueLEDPin, OUTPUT);
}

void loop() {

  if (digitalRead(switch1Pin) == HIGH) {
    activeLED++;
    if (activeLED > yellowLED) {
      activeLED = noLED;
    }
  }
  if (digitalRead(onOffPin) == HIGH) {
    //    if (redStatus || blueStatus || yellowStatus) {
    if (activeLED != noLED)  {

      if (activeLED == redLED) {
        activeLEDPin = redLEDPin;
      }
      else if (activeLED == blueLED) {
        activeLEDPin = blueLEDPin;
      }
      else if (activeLED == yellowLED) {
        activeLEDPin = yellowLEDPin;
      }
      else {
        Serial.println("WARNING");
      }
    }
    for (int v = lowPWM; v < maxPWM; v++) {
      delay(10);
      analogWrite(activeLEDPin, v);
      //          analogWrite(yellowLEDPin, v);
      //          analogWrite(blueLEDPin, v);
      //          analogWrite(redLEDPin, v);
    }

  }
}
else   {
  //
  //    for (int v = maxPWM; v > lowPWM; v--) {
  //      delay(10);
  //      analogWrite(yellowLEDPin, v);
  //      analogWrite(blueLEDPin, v);
  //      analogWrite(redLEDPin, v);
  //    }
  activeLED == noLED;
  analogWrite(yellowLEDPin, lowPWM);
  analogWrite(blueLEDPin, lowPWM);
  analogWrite(redLEDPin, lowPWM);
}

}