Fish Puppets

“Fish Puppets” Short Description: Fish puppets protecting their ocean home from Crisp-pollution. Medium Description: Smartphone controlled Puppets (Pi-ppet-duinos?) in a fishtank (ocean) fighting off things that are “crisp” (not supposed to be in the ocean). Inspirations: GGJ 2019 is at TPT, and when I think of public television, the first thing that comes to mind is the Muppets of Sesame Street. Lot of robot parts (servos, arduinos, Raspberry Pis) sitting around. Some stuffed animals I need to do something with. Diversifiers (see below) Limit of three GGJ19 diversifiers 1. Party Maker - (Sponsored by AirConsole) - Use AirConsole to make a computer game that uses smartphones as controllers (learn how do to this here). 2. Mixed Media - Make a physical game that utilizes computer code. 3. Protect the Oceans - Incorporate elements into your game to raise awareness about marine pollution (Goal number 14 on the UN Sustainable Development Goals). Local diversifier: "Crisp" Things that are supposed to be in the ocean are generally not “crisp”, so use the “crisp” local diversifier as the “enemy”. Move puppets to get rid of crisp items that are not supposed to be in the fish’s homes (what home means to you). Add some gold fish if the puppets work underwater (need to test this). Summarization: PBS location inspired idea to use puppets (Pi-ppet-duinos?) (Parts from robotics hobby, stuffed animals I need to do something with) 3 diversifiers: Smartphone controllers, Physical media using code, protect the oceans. Local diversifier “Crisp” represents stuff that isn’t supposed to be in the ocean.
Jam year: 
2019
Diversifiers: 
Party Maker - (Sponsored by AirConsole)
Mixed Media
Protect the Oceans
Platforms: 
Linux / Unix, Android device
Tools and Technologies: 
Ren/Py, Unity (any product)
Technology Notes: 
Android Studio - Hand controller program running on Android OS phones (smartphone controllers - sponsored diversifier). Raspberry Pi - Raspian OS interfacing Raspberry Pi Zero W board computers. Arduino IDE programming Arduino Nanos (physical media using computer code diversifier). Fish puppets using SG-90 Servo motor animatronics (Protect the oceans diversifier). Fish Tank representing fish's home ("What home means to you" GGJ 2019 Theme). Recycled Trash Items ("crisp" local diversifier)
Installation Instructions: 

// 1/26/2019  Stepper28BYJ-48 derived from
// Sweep example PWM servo sketch
// and BYJ48 Stepper Motor Instructable at
// https://www.instructables.com/id/BYJ48-Stepper-Motor/

/* Sweep
 by BARRAGAN <http://barraganstudio.com>
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/
/*
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}
*/
//start of stepper code
    /*
       BYJ48 Stepper motor code
       Connect :
       IN1 >> D8
       IN2 >> D9
       IN3 >> D10
       IN4 >> D11
       VCC ... 5V Prefer to use external 5V Source
       Gnd
       written By :Mohannad Rawashdeh
      https://www.instructables.com/member/Mohannad+Rawashdeh/
         28/9/2013
      */
// 1/26/2019 DmT: I'm using A6 to A3 as IN1 to IN4 instead of D8 to D11 in the example
// according to the Nano diagram, A6 is pin 20 (I think), A5 is 19, A4 is 18, and A3 is pin 17.
// Note:  A6/Pin 20 wasn't working well so switched IN1 to A2 or pin 16.
    #define IN1  16 // 20 // 8
    #define IN2  19 // 9
    #define IN3  18 // 10
    #define IN4  17 // 11

//Naming IN pins for the second stepper as IN#b to differentiate from the first four IN.
    #define IN1b  2
    #define IN2b  4
    #define IN3b  7
    #define IN4b  8
    
    int Steps = 0;
    int Steps2 = 0;
    boolean Direction = true;// gre
    boolean Direction2 = true;// gre
    unsigned long last_time;
    unsigned long currentMillis ;
    int steps_left=4095;
    long time;

    int led = 13;
    void setup()
    {
    Serial.begin(115200);
    pinMode(IN1, OUTPUT);
    pinMode(IN2, OUTPUT);
    pinMode(IN3, OUTPUT);
    pinMode(IN4, OUTPUT);

    pinMode(IN1b, OUTPUT);
    pinMode(IN2b, OUTPUT);
    pinMode(IN3b, OUTPUT);
    pinMode(IN4b, OUTPUT);

    // delay(1000);

  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

    
void loop()
    {
      while(steps_left>0){
        currentMillis = micros();
        if(currentMillis-last_time>=1000){
          stepper(1);
      digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
//      delay(1);               // wait for a second
          stepper2(1);
      digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
//      delay(1);               // wait for a second
          time=time+micros()-last_time;
          last_time=micros();
          steps_left--;
        }
      }
      Serial.println(time);
      Serial.println("Wait...!");
      digitalWrite(led, HIGH);
      delay(2000);
      digitalWrite(led, LOW);
      Direction=!Direction;
      Direction2=!Direction2;
      steps_left=12345;//
      //4095;

      Direction=!Direction;

      while(steps_left>0){
        currentMillis = micros();
        if(currentMillis-last_time>=1000){
          stepper(1);
      digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
//      delay(1);               // wait for a second
          stepper2(1);
      digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
//      delay(1);               // wait for a second
          time=time+micros()-last_time;
          last_time=micros();
          steps_left--;
        }
      }
      Serial.println(time);
      Serial.println("Wait...!");
      digitalWrite(led, HIGH);
      delay(2000);
      digitalWrite(led, LOW);
      Direction=!Direction;
      Direction2=!Direction2;
      steps_left=12345;//
      //4095;
}

void stepper(int xw){
      for (int x=0;x<xw;x++){
    switch(Steps){
       case 0:
         digitalWrite(IN1, LOW);
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, HIGH);
       break;
       case 1:
         digitalWrite(IN1, LOW);
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, HIGH);
         digitalWrite(IN4, HIGH);
       break;
       case 2:
         digitalWrite(IN1, LOW);
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, HIGH);
         digitalWrite(IN4, LOW);
       break;
       case 3:
         digitalWrite(IN1, LOW);
         digitalWrite(IN2, HIGH);
         digitalWrite(IN3, HIGH);
         digitalWrite(IN4, LOW);
       break;
       case 4:
         digitalWrite(IN1, LOW);
         digitalWrite(IN2, HIGH);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, LOW);
       break;
       case 5:
         digitalWrite(IN1, HIGH);
         digitalWrite(IN2, HIGH);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, LOW);
       break;
         case 6:
         digitalWrite(IN1, HIGH);
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, LOW);
       break;
       case 7:
         digitalWrite(IN1, HIGH);
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, HIGH);
       break;
       default:
         digitalWrite(IN1, LOW);
         digitalWrite(IN2, LOW);
         digitalWrite(IN3, LOW);
         digitalWrite(IN4, LOW);
       break;
    }
    SetDirection();
    }
}

void stepper2(int xw){
      for (int x=0;x<xw;x++){
    switch(Steps2){
       case 0:
         digitalWrite(IN1b, LOW);
         digitalWrite(IN2b, LOW);
         digitalWrite(IN3b, LOW);
         digitalWrite(IN4b, HIGH);
       break;
       case 1:
         digitalWrite(IN1b, LOW);
         digitalWrite(IN2b, LOW);
         digitalWrite(IN3b, HIGH);
         digitalWrite(IN4b, HIGH);
       break;
       case 2:
         digitalWrite(IN1b, LOW);
         digitalWrite(IN2b, LOW);
         digitalWrite(IN3b, HIGH);
         digitalWrite(IN4b, LOW);
       break;
       case 3:
         digitalWrite(IN1b, LOW);
         digitalWrite(IN2b, HIGH);
         digitalWrite(IN3b, HIGH);
         digitalWrite(IN4b, LOW);
       break;
       case 4:
         digitalWrite(IN1b, LOW);
         digitalWrite(IN2b, HIGH);
         digitalWrite(IN3b, LOW);
         digitalWrite(IN4b, LOW);
       break;
       case 5:
         digitalWrite(IN1b, HIGH);
         digitalWrite(IN2b, HIGH);
         digitalWrite(IN3b, LOW);
         digitalWrite(IN4b, LOW);
       break;
         case 6:
         digitalWrite(IN1b, HIGH);
         digitalWrite(IN2b, LOW);
         digitalWrite(IN3b, LOW);
         digitalWrite(IN4b, LOW);
       break;
       case 7:
         digitalWrite(IN1b, HIGH);
         digitalWrite(IN2b, LOW);
         digitalWrite(IN3b, LOW);
         digitalWrite(IN4b, HIGH);
       break;
       default:
         digitalWrite(IN1b, LOW);
         digitalWrite(IN2b, LOW);
         digitalWrite(IN3b, LOW);
         digitalWrite(IN4b, LOW);
       break;
    }
    SetDirection2();
    }
}

void SetDirection(){
    if(Direction==1){ Steps++;}
    if(Direction==0){ Steps--; }
    if(Steps>7){Steps=0;}
    if(Steps<0){Steps=7; }
}

void SetDirection2(){
    if(Direction2==1){ Steps2++;}
    if(Direction2==0){ Steps2--; }
    if(Steps2>7){Steps2=0;}
    if(Steps2<0){Steps2=7; }
}

Credits: 

"Fish Puppets" by Doug Thorpe and Sophie Robinson

Game Stills: