FluxP
Published © GPL3+

Sand Art Display

A Japanese zen garden built into a glass-covered picture frame.

IntermediateFull instructions provided1,996
Sand Art Display

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
see the construction manual PDF for all components.
×1
5 V stepper motor 28BYJ-48 with driver board ULN2003.
×2

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
see the construction manual PDF for all tools needed.

Story

Read more

Custom parts and enclosures

construction manual

construction manual

Schematics

Sand Art Display wiring diagram

Code

Sand Art Display program with three patterns

Arduino
Show !
/*
Stepper Motor Control progam for an X-Y table named "Sand Art Display".
This program drives two unipolar 5V DC stepper motors type 28BYJ-48.
The motors are attached to digital pins 4,5,6,7 and 8,9,10 and 11 of the Arduino UNO, 
via a driver board with IC ULN2003.
The motor power supply on this board is a separate 5V DC supply. 
GND is connected to the GND of the Arduino. 
The motors drive both axis of the sand art table with a 250 mm rack gear.
It starts the movement blue, yellow or white when the motors are resting in the full left & up position.
See www.apinventions.wordpress.com for the Sand Art Display building instructions.
Created March 12 2020 by Alex Pikkert.
*/

#include <Stepper.h>
//this sequence is special for the 28BYJ-48 stepper motor.
Stepper myStepperX(1024, 8,10,9,11);Stepper myStepperY(1024, 4,6,5,7);

int button    = A1; // analog button value 736(white)/451(yellow)/14(blue)
int select    = 0;  // select which road to follow... 
int resetled  = A2; // green led ready for instructions
int whiteled  = A3; // path 1
int yellowled = A4; // path 2
int blueled   = A5; // path 3
int xstop     = 12; // port end position left or right
int ystop     = 3;  // port end position up or down
int speed1    = 10; // slow speed
int speed2    = 15; // medium speed 
int speed3    = 25; // fast speed
int up        = 50; // length of standard step up
int down      = -50;// length of standard step down  
int left      = 50; // length of standard step left
int right     = -50;// length of standard step right
int n=0;            // counter flag up/down
int m=0;            // counter flag left/right
int x=0;            // left/right number of steps
int y=0;            // up/down number of steps
int d=0;            // counter for step difference

void setup() {
myStepperX.setSpeed(speed3);myStepperY.setSpeed(speed3);
pinMode(3,INPUT_PULLUP);pinMode(12,INPUT_PULLUP);pinMode(A1,INPUT_PULLUP);
pinMode(A2,OUTPUT);pinMode(A3,OUTPUT);pinMode(A4,OUTPUT);pinMode(A5,OUTPUT);
myStepperX.step(5*left);myStepperY.step(5*up);// always move to left/up corner start position
}

void loop() {
myStepperX.setSpeed(speed3);myStepperY.setSpeed(speed3);
digitalWrite(whiteled,LOW);digitalWrite(yellowled,LOW);digitalWrite(blueled,LOW);
y = digitalRead(ystop);if(y==HIGH) {myStepperY.step(4*up);}
x= digitalRead(xstop);if(x==HIGH) {myStepperX.step(4*left);}

if (y==LOW && x==LOW) // left/up start position
{ digitalWrite(resetled,HIGH);
  select = analogRead(button);
  if (select <50){blue();}
  if (select >50 && select <600){yellow();}
  if (select >600 && select <800){white();}
}

}
//PONG
void blue(){
myStepperX.setSpeed(speed2);myStepperY.setSpeed(speed2);
digitalWrite(blueled,HIGH);digitalWrite(resetled,LOW);

y = digitalRead(ystop);if(y==LOW && n==0){myStepperY.step(4*down);n=1;}
y = digitalRead(ystop);if(y==HIGH && n==1){myStepperY.step(2*down);}
y = digitalRead(ystop);if(y==LOW && n==1){myStepperY.step(4*up);n=0;} 
y = digitalRead(ystop);if(y==HIGH && n==0){myStepperY.step(2*up);}

x = digitalRead(xstop);if(x==LOW && m==0){myStepperX.step(4*right);m=1;}
x = digitalRead(xstop);if(x==HIGH && m==1){myStepperX.step(2*right);}
x = digitalRead(xstop);if(x==LOW && m==1){myStepperX.step(4*left);m=0;} 
x = digitalRead(xstop);if(x==HIGH && m==0){myStepperX.step(2*left);}
blue();
}

//PLOUGH
void yellow(){
myStepperX.setSpeed(speed2);myStepperY.setSpeed(speed2);
digitalWrite(yellowled,HIGH);digitalWrite(resetled,LOW);
x=73-d;myStepperX.step(x*right);
y=56-d;myStepperY.step(y*down);
d=d+3;
x=73-d;myStepperX.step(x*left);
y=56-d;myStepperY.step(y*up);
d=d+3;
while(y<5 || x< 5){} ;
yellow();
}

//WAFFLE 
void white(){
myStepperX.setSpeed(speed2);myStepperY.setSpeed(speed2);
digitalWrite(whiteled,HIGH);digitalWrite(resetled,LOW);
if(d==0){
if(n==0){myStepperY.step(5*down);}
y = digitalRead(ystop);if(y==LOW && n==0){myStepperX.step(11*right);n=1;x=x+1;}
if(n==1){myStepperY.step(5*up);}
y = digitalRead(ystop);if(y==LOW && n==1){myStepperX.step(11*right);n=0;x=x+1;}
if(x >7){d=1;y=0;n=0;}
}
if (d==1){
if(n==0){myStepperX.step(5*left);}
x = digitalRead(xstop);if(x==LOW && n==0){myStepperY.step(11*down);n=1;y=y+1;}
if(n==1){myStepperX.step(5*right);}
x = digitalRead(xstop);if(x==LOW && n==1){myStepperY.step(11*down);n=0;y=y+1;}
while(y >5){};
}
white();
}

Credits

FluxP

FluxP

1 project • 0 followers

Comments