Tag Archives: stupid pet trick

Flappy Bird, Remembered

This is a rudimentary model of the iPhone game, Flappy Birds. I originally wanted the pipe ┬ástructure to be automated by a motor, but that system had too many complications. Thus the version you see in the video is simply hand-operated. Don’t hit the pipes or the ceiling or your flappy bird will fall.

The green LED indicates that the game is on, while the red LED indicates that the game is over.

To the flappiest of the birds, you will be missed.

https://www.youtube.com/watch?v=Li0RaOC3BpM&feature=youtu.be

The motor (if it had worked)
The entire setup
Are you ready to play?

 

#include <Servo.h>
Servo servoMain; // Define  Servo
void setup()
{
  Serial.begin(9600);
  servoMain.attach(A0); // servo on pin 7
  pinMode(A3, INPUT); //touch sensor input
  pinMode(1, INPUT);
  pinMode(2, OUTPUT);

  pinMode(3, OUTPUT); //LED game start
  pinMode(4, OUTPUT); //LED game over

}

void loop()
{
  int angle = 0;
  int stat = 3;
  for (int go = 0; go < 1000000;){
    delay(25);
    Serial.println(analogRead(A3));
    digitalWrite(3, HIGH);
    if (analogRead(A3) >= 5){
      angle++;
      digitalWrite(4, LOW);
    }
    else {
      angle--;
      digitalWrite(4, LOW);
    }
    if (angle < 30){
      angle = 30;
      digitalWrite(4, HIGH);
      digitalWrite(3, LOW);
    }
    if (angle > 110){
      angle = 110;
      digitalWrite(4, HIGH);
      digitalWrite(3, LOW);
    }
  servoMain.write(angle);

}

}

 

ASL to LED (AKA American Sign LED-uage)

For my project I wanted to combine American Sign Language and what we’ve been working on in class. So I decided to translate the sign language alphabet into Morse code (done through flashes on an LED). I used two flex sensors, one on my thumb and one on my forefinger to do so. For this project I only did the letters A through H because to go past that I would need another flex sensor as well as an accelerometer to accurately transmit the letters. However, for A through H only the thumb sensor would technically be needed, but for accuracy (and I bought the thing so I figured why not) I used the one on the forefinger as well. It took me a while to figure out exactly how to code it and I feel like there would be a way to shorten down the code, but I did not know how at this point. But the biggest time consumer was figuring out the sensor ranges needed to code. And here is the video explaining some of this and a demonstration.

//all the alphabet used to monitor my accuracy of handshapes
// to make sure it was picking up the right letter.
int A = 1;
int B = 2;
int C = 3;
int D = 4;
int E = 5;
int F = 6;
int G = 7;
int H = 8;
int dot = 500;
int dash = 1000;
int pause = 200;
void setup(){
  pinMode (8, OUTPUT);
  Serial.begin(9600);

}

void loop(){
  int input = analogRead(A1);
  int inputF = analogRead (A2);
  int flexFore = map (inputF, 320, 557, 0, 100);
  int flexNumbers = map(input, 360, 540, 0, 100);

  if (flexNumbers >= 90 && flexNumbers <=100){
    if (flexFore >= 25 && flexFore < 35){
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
      Serial.println(A);
    delay(3000);
    }
  }

   else if (flexNumbers >= 80 && flexNumbers <90){
     if (flexFore >=80 && flexFore <95) {
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
       Serial.println(H);
    delay(3000);
     }
  }
  else if (flexNumbers >=70 && flexNumbers <80) {
    if (flexFore >= 80 && flexFore <95){
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);  
    Serial.println(G);
    delay(3000);
    }
  }
  else if (flexNumbers >=60 && flexNumbers <70){
    if (flexFore >=50 && flexFore <60){
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);  
    Serial.println(C);
    delay(3000);
    }
  }
  else if (flexNumbers >=50 && flexNumbers <60) {
    if (flexFore >=30 && flexFore <40){
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
      Serial.println(F);
    delay(3000);
    }
  }
  else if (flexNumbers >=40 && flexNumbers <50) {
    if (flexFore >= 90 && flexFore <=100){
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
      Serial.println(D);
    delay(3000);
    }
  }
  else if (flexNumbers >=30 && flexNumbers <40){
    if (flexFore >=90 && flexFore <=100){
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
      Serial.println(B);
    delay(3000);
    }
  }
  else if (flexNumbers <30){
    if (flexFore >= 0 && flexFore < 20){
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
      Serial.println(E);
    delay(3000);
    }
  }

}