Assignment 4: Story of Motion

Tell a short story with movement, due 23:59, Wed, 11 Oct, posted to this category

Requirement: a story that can be told with motion.   Must use H-bridge controller, can use any other hardware in the lab or that you fab.

If we our out of h-bridge chips or you need a motor that we’ve run out of in A10, email and I’ll replace them ASAP.  Also check with lending to see if they have a motor or h-bridge you can use in the short term.

Stories have at least three states:

  • start: everything is static (not moving) or moving in an idle loop
  • story: motion tells a story
    • rotating things
      • ferris wheel, merry go round
      • pulleys that wind or release string
    • fan that blows things across a table
    • object that moves on a table
    • switches that start/stop movement
  • ending: the story comes to an end or goes back to the start and waits to be told again.

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);
}

Assignment 3: Motorized Emotions

Motorized Emotions:  Make a kinetic interaction that expresses an emotion.

Due:  Wed, 27 Sep, 23:59hrs.

Find an emotion you can display with motion.  A couple of examples I used in class:

  • Light makes plants happy:  Use a photoresistor to detect light and create more motion when there is more light, less motion when it is dark.
  • Cats like to be petted:  Use buttons or other inputs to “pet” your cat, use a servo for a wagging tail and tactors to simulate purring.

Document your project with a Fritzing sketch of your circuit, an Arduino sketch, and video.  I’d like everyone to demonstrate these in class on the following Thursday.

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: