close-circle
Close

Arduino SPFetch 150

A project log for Arduino Sand Matrix Printer

1 ppi (FAIL)

Vije Miller 08/27/2017 at 06:030 Comments
// Arduino Sand Matrix Printer
// VijeMiller
#include <Servo.h>
Servo p1;
Servo p2;
Servo p3;
Servo p4;
Servo p5;
// Servo Angles
int up = 120;
int down = 180;
// Servo Print Delay
int pers = 250;
char data = 0;
void setup() {
  Serial.begin(9600);
  // Servo Pins
  p1.attach(8); // Bcz 3 Went Wonky
  p2.attach(4);
  p3.attach(5);
  p4.attach(6);
  p5.attach(7);
  p1.write(up);
  p2.write(up);
  p3.write(up);
  p4.write(up);
  p5.write(up);
}
void loop() {
  if (Serial.available() > 0)
  {
    data = Serial.read();
    Serial.println(data);
    if (data == 'a') {
      a();
    } else if (data == 'b') {
      b();
    } else if (data == 'c') {
      c();
    } else if (data == 'd') {
      d();
    } else if (data == 'e') {
      e();
    } else if (data == 'f') {
      f();
    } else if (data == 'g') {
      g();
    } else if (data == 'h') {
      h();
    } else if (data == 'i') {
      i();
    } else if (data == 'j') {
      j();
    } else if (data == 'k') {
      k();
    } else if (data == 'l') {
      l();
    } else if (data == 'm') {
      m();
    } else if (data == 'n') {
      n();
    } else if (data == 'o') {
      o();
    } else if (data == 'p') {
      p();
    } else if (data == 'q') {
      q();
    } else if (data == 'r') {
      r();
    } else if (data == 's') {
      s();
    } else if (data == 't') {
      t();
    } else if (data == 'u') {
      u();
    } else if (data == 'v') {
      v();
    } else if (data == 'w') {
      w();
    } else if (data == 'x') {
      x();
    } else if (data == 'y') {
      y();
    } else if (data == 'z') {
      z();
    } else if (data == '1') {
      one();
    } else if (data == '2') {
      two();
    } else if (data == '3') {
      three();
    } else if (data == '4') {
      four();
    } else if (data == '5') {
      five();
    } else if (data == '6') {
      next();
    }
  }
  data = 0;
  delay(10);
}
void next() {
  // Next Column
  // Original Design (360 Servo)
  // Blew Out Servo, Manual Drag, Sigh
  delay(500);
}
void space() {
  // Next Column x 1.5
  delay(1000);
}
void a() {
  // ooxoo
  // oxoxo
  // xxxxx
  // xooox
  // xooox
  p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p3.write(up); p4.write(up); p5.write(up);
  next();
  p2.write(down); p3.write(down); delay(pers);
  p2.write(up); p3.write(up);
  next();
  p1.write(down); p3.write(down); delay(pers);
  p1.write(up); p3.write(up);
  next();
  p2.write(down); p3.write(down); delay(pers);
  p2.write(up); p3.write(up);
  next();
  p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p3.write(up); p4.write(up); p5.write(up);
  space();
}
void b() {
  // xxxxo
  // xooox
  // xxxxx
  // xooox
  // xxxxo
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p2.write(up); p3.write(up); p4.write(up);
  space();
}
void c() {
  // oxxxx
  // xoooo
  // xoooo
  // xoooo
  // oxxxx
  p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p2.write(up); p3.write(up); p4.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  space();
}
void d() {
  // xxxxo
  // xooox
  // xooox
  // xooox
  // xxxxo
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p2.write(up); p3.write(up); p4.write(up);
  space();
}
void e() {
  // xxxxx
  // xoooo
  // xxxxo
  // xoooo
  // xxxxx
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  space();
}
void f() {
  // xxxxx
  // xoooo
  // xxxxo
  // xoooo
  // xoooo
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); delay(pers);
  p1.write(up); p3.write(up);
  next();
  p1.write(down); p3.write(down); delay(pers);
  p1.write(up); p3.write(up);
  next();
  p1.write(down); p3.write(down); delay(pers);
  p1.write(up); p3.write(up);
  next();
  p1.write(down); delay(pers);
  p1.write(up);
  space();
}
void g() {
  // oxxxx
  // xoooo
  // xooxx
  // xooox
  // oxxxx
  p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p2.write(up); p3.write(up); p4.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(down); p5.write(up);
  next();
  p1.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(down); p4.write(down); p5.write(up);
  space();
}
void h() {
  // xooox
  // xooox
  // xxxxx
  // xooox
  // xooox
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p3.write(down); delay(pers);
  p3.write(up);
  next();
  p3.write(down); delay(pers);
  p3.write(up);
  next();
  p3.write(down); delay(pers);
  p3.write(up);
  next();
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  space();
}
void i() {
  // xxxxx
  // ooxoo
  // ooxoo
  // ooxoo
  // xxxxx
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  space();
}
void j() {
  // ooxxx
  // oooox
  // oooox
  // xooox
  // oxxxo
  p4.write(down); delay(pers);
  p4.write(up);
  next();
  p5.write(down); delay(pers);
  p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up);
  space();
}
void k() {
  // xooox
  // xooxo
  // xxxoo
  // xooxo
  // xooox
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p3.write(down); delay(pers);
  p3.write(up);
  next();
  p3.write(down); delay(pers);
  p3.write(up);
  next();
  p2.write(down); p4.write(down); delay(pers);
  p2.write(up); p4.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  space();
}
void l() {
  // xoooo
  // xoooo
  // xoooo
  // xoooo
  // xxxxx
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p5.write(down); delay(pers);
  p5.write(up);
  next();
  p5.write(down); delay(pers);
  p5.write(up);
  next();
  p5.write(down); delay(pers);
  p5.write(up);
  next();
  p5.write(down); delay(pers);
  p5.write(up);
  space();
}
void m() {
  // xooox
  // xxoxx
  // xoxox
  // xooox
  // xooox
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p2.write(down); delay(pers);
  p2.write(up);
  next();
  p3.write(down); delay(pers);
  p3.write(up);
  next();
  p2.write(down); delay(pers);
  p2.write(up);
  next();
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  space();
}
void n() {
  // xooox
  // xxoox
  // xoxox
  // xooxx
  // xooox
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p2.write(down); delay(pers);
  p2.write(up);
  next();
  p3.write(down); delay(pers);
  p3.write(up);
  next();
  p4.write(down); delay(pers);
  p4.write(up);
  next();
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  space();
}
void o() {
  // oxxxo
  // xooox
  // xooox
  // xooox
  // oxxxo
  p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p2.write(up); p3.write(up); p4.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p2.write(up); p3.write(up); p4.write(up);
  space();
}
void p() {
  // xxxxo
  // xooox
  // xxxxo
  // xoooo
  // xoooo
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); delay(pers);
  p1.write(up); p3.write(up);
  next();
  p1.write(down); p3.write(down); delay(pers);
  p1.write(up); p3.write(up);
  next();
  p1.write(down); p3.write(down); delay(pers);
  p1.write(up); p3.write(up);
  next();
  p2.write(down); delay(pers);
  p2.write(up);
  space();
}
void q() {
  // oxxxo
  // xooox
  // xoxox
  // xooxx
  // oxxxx
  p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p2.write(up); p3.write(up); p4.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p4.write(up); p5.write(up);
  next();
  p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  space();
}
void r() {
  // xxxxo
  // xooox
  // xxxxo
  // xooxo
  // xooox
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); delay(pers);
  p1.write(up); p3.write(up);
  next();
  p1.write(down); p3.write(down); delay(pers);
  p1.write(up); p3.write(up);
  next();
  p1.write(down); p3.write(down); p4.write(down); delay(pers);
  p1.write(up); p3.write(up); p4.write(up);
  next();
  p2.write(down); p5.write(down); delay(pers);
  p2.write(up); p5.write(up);
  space();
}
void s() {
  // xxxxx
  // xoooo
  // xxxxx
  // oooox
  // xxxxx
  p1.write(down); p2.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p4.write(up); p5.write(up);
  space();
}
void t() {
  // xxxxx
  // ooxoo
  // ooxoo
  // ooxoo
  // ooxoo
  p1.write(down); delay(pers);
  p1.write(up);
  next();
  p1.write(down); delay(pers);
  p1.write(up);
  next();
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p1.write(down); delay(pers);
  p1.write(up);
  next();
  p1.write(down); delay(pers);
  p1.write(up);
  space();
}
void u() {
  // xooox
  // xooox
  // xooox
  // xooox
  // oxxxo
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up);
  next();
  p5.write(down); delay(pers);
  p5.write(up);
  next();
  p5.write(down); delay(pers);
  p5.write(up);
  next();
  p5.write(down); delay(pers);
  p5.write(up);
  next();
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up);
  space();
}
void v() {
  // xooox
  // xooox
  // xooox
  // oxoxo
  // ooxoo
  p1.write(down); p2.write(down); p3.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up);
  next();
  p4.write(down); delay(pers);
  p4.write(up);
  next();
  p5.write(down); delay(pers);
  p5.write(up);
  next();
  p4.write(down); delay(pers);
  p4.write(up);
  next();
  p1.write(down); p2.write(down); p3.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up);
  space();
}
void w() {
  // xooox
  // xooox
  // xoxox
  // xxoxx
  // xooox
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  next();
  p4.write(down); delay(pers);
  p4.write(up);
  next();
  p3.write(down); delay(pers);
  p3.write(up);
  next();
  p4.write(down); delay(pers);
  p4.write(up);
  next();
  p1.write(down); p2.write(down); p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p3.write(up); p4.write(up); p5.write(up);
  space();
}
void x() {
  // xooox
  // oxoxo
  // ooxoo
  // oxoxo
  // xooox
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p2.write(down); p4.write(down); delay(pers);
  p2.write(up); p4.write(up);
  next();
  p3.write(down); delay(pers);
  p3.write(up);
  next();
  p2.write(down); p4.write(down); delay(pers);
  p2.write(up); p4.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  space();
}
void y() {
  // xooox
  // oxoxo
  // ooxoo
  // ooxoo
  // ooxoo
  p1.write(down); delay(pers);
  p1.write(up);
  next();
  p2.write(down); delay(pers);
  p2.write(up);
  next();
  p3.write(down); p4.write(down); p5.write(down); delay(pers);
  p3.write(up); p4.write(up); p5.write(up);
  next();
  p2.write(down); delay(pers);
  p2.write(up);
  next();
  p1.write(down); delay(pers);
  p1.write(up);
  space();
}
void z() {
  // xxxxx
  // oooxo
  // ooxoo
  // oxooo
  // xxxxx
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  next();
  p1.write(down); p4.write(down); p5.write(down); delay(pers);
  p1.write(up); p4.write(up); p5.write(up);
  next();
  p1.write(down); p3.write(down); p5.write(down); delay(pers);
  p1.write(up); p3.write(up); p5.write(up);
  next();
  p1.write(down); p2.write(down); p5.write(down); delay(pers);
  p1.write(up); p2.write(up); p5.write(up);
  next();
  p1.write(down); p5.write(down); delay(pers);
  p1.write(up); p5.write(up);
  space();
}
void one() {
  p1.write(down);
  delay(pers);
  p1.write(up);
}
void two() {
  p2.write(down);
  delay(pers);
  p2.write(up);
}
void three() {
  p3.write(down);
  delay(pers);
  p3.write(up);
}
void four() {
  p4.write(down);
  delay(pers);
  p4.write(up);
}
void five() {
  p5.write(down);
  delay(pers);
  p5.write(up);
}

Discussions