Erica’s project prototype and tutorial draft

“CODE STORYBOARD”

#0: way for both products to connect to their own wi-fi

#1-2 NO ACTIVITY:

  • Inputs: listening onflickerAandflickerB, neither registers any flick
  • Outputs: no motor movement, no LED lighting

#3-6 CAT A FLICKS THEIR TOY (steps below) OR CAT B FLICKS THEIR TOY (skip to step #9)

  • Inputs: listening onflickerAandflickerB,flickerA registers a flick. No more flicks will be registered for the next 10(?) minutes.
  • Outputs:motorAcontinues to return nothing.ledA1lights up red for 2 minutes andledA2continues to return nothing.motorBstarts moving for next 2(?) minutes. ledA1continues to return nothing andledA2lights up blue for 2 minutes.

#7-8 SENSORS AND MOTORS BECOME INACTIVE FOR 10(?) minutes

  • Inputs: For the next 10 minutes, areflickerAandflickerB listening and not returning anything? Or do they stop listening completely?
  • Outputs: motorA,ledA1,ledA2,motorB,ledA1, andledA2all return nothing.

#9-11 CAT B FLICKS THEIR TOY (steps below) OR CAT A FLICKS THEIR TOY (skip to step #3) OR NO CAT DOES ANYTHING (skip to step #1)

  • Inputs: listening onflickerAandflickerB,flickerBregisters a flick. No more flicks will be registered for the next 10(?) minutes.
  • Outputs:motorAstarts moving for next 2(?) minutes.ledA1continues to return nothing andledA2lights up green for 2 minutes.motorBcontinues to return nothing.ledA1lights up red for 2 minutes andledA2continues to return nothing.

DRAFT/STARTING POINT CODE (needs help!)

// Instructables Internet of Things Class sample code
// Combining Inputs and Outputs
// Two pushbuttons send commands to AIO feed
// LED and vibrating motor (or any digital output) flah/buzz according to feed data
//
// Modified by Becky Stern 2017
// based on examples from Adafruit IO Arduino Library:
// https://github.com/adafruit/Adafruit_IO_Arduino
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.

/************************ Adafruit IO Configuration *******************************/

// visit io.adafruit.com if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_USERNAME    "efink"
#define IO_KEY         "aio_REXk04E1ptOfh1h0E4kwcXUdqjd0"

/******************************* WIFI Configuration **************************************/

#define WIFI_SSID       "Internet Of Things Class"
#define WIFI_PASS       "iheartarduino"

#include "AdafruitIO_WiFi.h"
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);

/************************ Main Code Starts Here *******************************/

#include <ESP8266WiFi.h>
#include <AdafruitIO.h>
#include <Adafruit_MQTT.h>
#include <ArduinoHttpClient.h>

#define AToyLED1_PIN 1
#define AToyLED2_PIN 2
#define AToyFLICK_PIN 3
#define AToyMOTOR_PIN 5 // this pin needs PWM capability

#define BToyLED1_PIN 7
#define BToyLED2_PIN 8
#define BToyFLICK_PIN 9
#define BToyMOTOR_PIN 6 // this pin needs PWM capability

// flick "button" state
int current = 0;
int last = 0;

// set up the 'digital' feed
AdafruitIO_Feed *catcommand = io.feed("catcommand");

void setup() {

  // set button pins as inputs with internal pull-up resistor
  pinMode(AToyFLICK_PIN, INPUT_PULLUP);
  pinMode(BToyFLICK_PIN, INPUT_PULLUP);
  // set led pin and motor pin as a digital outputs
  pinMode(AToyMOTOR_PIN, OUTPUT);
  pinMode(BToyMOTOR_PIN, OUTPUT);

  pinMode(AToyLED1_PIN, OUTPUT);
  pinMode(AToyLED2_PIN, OUTPUT);
  pinMode(BToyLED1_PIN, OUTPUT);
  pinMode(BToyLED2_PIN, OUTPUT);

  // start the serial connection
  Serial.begin(115200);

  // connect to io.adafruit.com
  Serial.print("Connecting to Adafruit IO");
  io.connect();
  
  // set up a message handler for the 'command' feed.
  // the handleMessage function (defined below)
  // will be called whenever a message is
  // received from adafruit io.
  command->onMessage(handleMessage);

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  // we are connected
  Serial.println();
  Serial.println(io.statusText());

}

void loop() {

  // io.run(); is required for all sketches.
  // it should always be present at the top of your loop
  // function. it keeps the client connected to
  // io.adafruit.com, and processes any incoming data.
  io.run();

  // grab the current state of the FLICK "button".
  // we have to flip the logic because we are
  // using INPUT_PULLUP.
  if(digitalRead(AToyFLICK_PIN) == LOW)
    current = 1;
  if (digitalRead(BToyFLICK_PIN) == LOW)
    current = 2;
  if (digitalRead(AToyFLICK_PIN) == HIGH && digitalRead(BToyFLICK_PIN) == HIGH)
    current = 0;

  // return if the value hasn't changed
  if(current == last)
    return;

  // save the current state to the 'digital' feed on adafruit io
  Serial.print("sending FLICK button -> ");
  Serial.println(current);
  command->save(current);

  // store last button state
  last = current;

}

// this function is called whenever a 'command' message
// is received from Adafruit IO. it was attached to
// the command feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {

  int command = data->toInt();

  if (command == 1){ //move the motor and light up the pins sequentially
    Serial.print("received <- ");
    Serial.println(command);
     analogWrite(BToyMOTOR_PIN, 200);
     delay(500);
     analogWrite(BToyMOTOR_PIN, 0);
     
    Serial.print("received <- ");
    Serial.println(command);
      digitalWrite(AToyLED1_PIN, HIGH);
      delay(500);
      digitalWrite(AToyLED2_PIN, LOW);
  
  } else if (command == 2) {
    Serial.print("received <- ");
    Serial.println(command);
     analogWrite(AToyMOTOR_PIN, 200);
     delay(500);
     analogWrite(AToyMOTOR_PIN, 0);
     
    Serial.print("received <- ");
    Serial.println(command);
      digitalWrite(BToyLED1_PIN, HIGH);
      delay(500);
      digitalWrite(BToyLED2_PIN, LOW);

  } else {
    Serial.print("received <- ");
    Serial.println(command);
  }
}

PRODUCT MAKING PLAN

  • (2) Solder components
  • (2) Make container (acrylic box? how to make it a curved object? Learn 3D printing?)
  • (2) Attachment for wall(?)
  • (2) Feathery ball attachments
  • (2) Spring steel wire (with way to attach in container)
  • (2) Obtain long enough USB cords

TUTORIAL OUTLINE:

Google doc: https://docs.google.com/document/d/1gga2Fp8uAJyMUhNYvYKwfe4SJZJ1aZjJvbeOmKZ9WwE/edit?usp=sharing

Instructables profile: https://www.instructables.com/member/efink/

PROJECT VIDEO PLAN

SHOT 0: (BACKUP ROLL IN CASE REDOING OPENING) Model shot closeups of Cat B and Cat B. fun music playing. Names overlayed etc.

SHOT 1: Silence, cricket sound effects. At Cat A’s home. Tripod is set up for a while, cat is resting on rug. Screen STILLS for a moment and text overlay name of cat, owner’s name, location.

SHOT 2: “”. toyA is now on the wall. Cat gets up and starts to play with it. Fun music picks up again.

SHOT 3: At Cat B’s home. Tripod is set up for a while. ToyB starts moving. CatB rushes over/watches it/starts playing with it. Screen STILLS for a moment and text overlay name of cat, owner’s name, location.

SHOT 4: Split screen of cats playing.

SHOT 5: Owner of each cat enters their shot and sits on floor with cat playing. They take a photo of it and text on their phones, smiling.

SHOT 6: Text screen with selfie of one person with their cat playing.

SHOT 7: Response selfie text.

SHOT 8: Full rewind.

SHOT 9: Rotate camera on tripod and zoom in on product.

SHOT 10: Product still side by side with circuit drawing

SHOT 11: Blooper reel of cats including zoom ins.

Leave a Reply

%d