Fakhr El-deen GamalMohamed Sami
Published © CC BY-NC-SA

CNC Plotter

Mobile-controlled CNC plotter.

AdvancedWork in progress25,925

Things used in this project

Story

Read more

Custom parts and enclosures

CNC Plotter Design

Schematics

Circuit Schematic

Code

CNC Writing Code

C/C++
It Writes any Word Of (5) Letters
FUTURE WORK :
-Control It by Voice
#define CUSTOM_SETTINGS
#define INCLUDE_KEYBOARD_SHIELD
#define INCLUDE_LCD_SHIELD

#include <OneSheeld.h>
#include <Servo.h>
#include<AFMotor.h>

AF_Stepper motorx(200, 1);
AF_Stepper motory(200, 2);

Servo myservo;

char dataArray[6];
int counter = 0;
int flag =0;
void setup() {
  // put your setup code here, to run once:
  OneSheeld.begin();
  motorx.setSpeed(40);
  motory.setSpeed(40);
  myservo.attach(9);
  AsciiKeyboard.setOnButtonChange(&myFunction);

}

void loop() {
  // put your main code here, to run repeatedly:

}


void myFunction(char data)
{
  dataArray[counter] = data;
  counter ++ ;

  if(counter == 5)
  {
    counter = 0;
    for (int i=0;i<5;i++)
    {
    switch (dataArray[flag]) {
    case 'A':
       Aletter();
      break;
    case 'B':
      Bletter();
      break;
    case 'C':
      Cletter();
      break;  
     case 'D':
      Dletter();
      break;
    case 'E':
      Eletter();
      break;
     case 'F':
      Fletter();
      break;
     case 'G':
      Gletter();
      break;
     case 'H':
      Hletter();
      break;
     case 'I':
      Iletter();
      break;
     case 'J':
      Jletter();
      break;
     case 'K':
      Kletter();
      break; 
     case 'L':
      Lletter();
      break;
     case 'M':
      Mletter();
      break;
     case 'N':
      Nletter();
      break;
     case 'O':
      Oletter();
      break;
     case 'P':
      Pletter();
      break;
     case 'Q':
      Qletter();
      break;
     case 'R':
      Rletter();
      break;
     case 'S':
      Sletter();
      break;
     case 'T':
      Tletter();
      break;
     case 'U':
      Uletter();
      break;
     case 'V':
      Vletter();
      break;
     case 'W':
      Wletter();
      break;
     case 'X':
      Xletter();
      break;
     case 'Y':
      Yletter();
      break;
     case 'Z':
      Zletter();
      break;
    
    }
    flag++ ; 
  }
  }
}


void Zletter()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
  myservo.write(53);
  motory.step(300, BACKWARD, INTERLEAVE);
  for (int i =0;i<380;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(1, FORWARD, INTERLEAVE);  
  } 
  motorx.step(120, FORWARD, INTERLEAVE);
  motory.step(300, BACKWARD, INTERLEAVE); 
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE); 
}


void Oletter()
{
  myservo.write(20);
  motory.step(130, BACKWARD, INTERLEAVE); //space
  motorx.step(400, FORWARD, INTERLEAVE);

  myservo.write(53);
  motorx.step(500, BACKWARD, INTERLEAVE);
  motory.step(300, BACKWARD, INTERLEAVE);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(300, FORWARD, INTERLEAVE);// O letter
  
  myservo.write(20);
  motory.step(300, BACKWARD, INTERLEAVE); 
  motorx.step(500, BACKWARD, INTERLEAVE);
}


void Nletter()
{

  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  motorx.step(500, FORWARD, INTERLEAVE);
  
  myservo.write(53);
  motorx.step(500, BACKWARD, INTERLEAVE);
  for (int i =0;i<350;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  motorx.step(400, BACKWARD, INTERLEAVE); // N letter
}


void Eletter()
{
  myservo.write(20);
  motory.step(400, BACKWARD, INTERLEAVE); //space


  myservo.write(53);
  motory.step(300, FORWARD, INTERLEAVE);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(300, BACKWARD, INTERLEAVE);

  myservo.write(20);
  motory.step(300, FORWARD, INTERLEAVE);
  motorx.step(250, BACKWARD, INTERLEAVE);

  myservo.write(53);
  motory.step(220, BACKWARD, INTERLEAVE);// E letter
  
  myservo.write(20);
  motory.step(80, BACKWARD, INTERLEAVE);
  motorx.step(250, BACKWARD, INTERLEAVE);
}

void Lletter()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
  myservo.write(53);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(300, BACKWARD, INTERLEAVE);
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);

}

void Aletter()
{
   myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  motorx.step(500, FORWARD, INTERLEAVE);
  myservo.write(53);
  motorx.step(500, BACKWARD, INTERLEAVE);
 
  motory.step(300, BACKWARD, INTERLEAVE);
  motorx.step(500, FORWARD, INTERLEAVE);
 
  myservo.write(20);
  motory.step(300, FORWARD, INTERLEAVE);
  motorx.step(200, BACKWARD, INTERLEAVE);
 
  myservo.write(53);
  motory.step(300, BACKWARD, INTERLEAVE);
 
  myservo.write(20);
  motorx.step(300, BACKWARD, INTERLEAVE);
}

void Bletter ()
{
   myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
  myservo.write(53);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(200, BACKWARD, INTERLEAVE);
  motorx.step(200, BACKWARD, INTERLEAVE);
  motory.step(200, FORWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(300, BACKWARD, INTERLEAVE); //space
}

void Cletter ()
{
   myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
   myservo.write(53);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(200, BACKWARD, INTERLEAVE);
  motorx.step(100, BACKWARD, INTERLEAVE);
  
  myservo.write(20);
  motory.step(200, FORWARD, INTERLEAVE);
  motorx.step(400, BACKWARD, INTERLEAVE);
  
  myservo.write(53);
  motory.step(200, BACKWARD, INTERLEAVE);
  motorx.step(100, FORWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(100, BACKWARD, INTERLEAVE); 
}

void Dletter ()
{
   myservo.write(20);
  motory.step(300, BACKWARD, INTERLEAVE); //space
  
   myservo.write(53);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(200, FORWARD, INTERLEAVE);
  motorx.step(200, BACKWARD, INTERLEAVE);
  motory.step(200, BACKWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(300, BACKWARD, INTERLEAVE);  
}

void Fletter()
{
  myservo.write(20);
  motory.step(400, BACKWARD, INTERLEAVE); //space


  myservo.write(53);
  motory.step(300, FORWARD, INTERLEAVE);
  delay(200);
  motorx.step(500, FORWARD, INTERLEAVE);
  delay(200);
  

  myservo.write(20);
  motorx.step(200, BACKWARD, INTERLEAVE);

  myservo.write(53);
  motory.step(250, BACKWARD, INTERLEAVE);// E letter
  
}

void Gletter ()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
   myservo.write(53);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(200, BACKWARD, INTERLEAVE);
  motorx.step(100, BACKWARD, INTERLEAVE);
  motory.step(50, FORWARD, INTERLEAVE);
  motory.step(100, BACKWARD, INTERLEAVE);
  motory.step(50, FORWARD, INTERLEAVE);
  
  myservo.write(20);
  motory.step(200, FORWARD, INTERLEAVE);
  motorx.step(400, BACKWARD, INTERLEAVE);
  
  myservo.write(53);
  motory.step(200, BACKWARD, INTERLEAVE);
  motorx.step(100, FORWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(100, BACKWARD, INTERLEAVE);
}

void Hletter()
{
    myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
  myservo.write(53);
  motorx.step(500, FORWARD, INTERLEAVE);  
  
  myservo.write(20);
  motorx.step(250, BACKWARD, INTERLEAVE);
 
  myservo.write(53);
  motory.step(200, BACKWARD, INTERLEAVE);
  motorx.step(250, FORWARD, INTERLEAVE); 
  motorx.step(500, BACKWARD, INTERLEAVE);    
}

void Iletter()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
   
   myservo.write(53);
  motory.step(200, BACKWARD, INTERLEAVE);
  motory.step(100, FORWARD, INTERLEAVE);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(100, FORWARD, INTERLEAVE);
  motory.step(200, BACKWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);
}

void Jletter()
{
  myservo.write(20);
  motory.step(200, BACKWARD, INTERLEAVE); //space 
  
   myservo.write(53);
  motory.step(200, BACKWARD, INTERLEAVE);
  motory.step(100, FORWARD, INTERLEAVE);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(200, FORWARD, INTERLEAVE);
  motorx.step(100, BACKWARD, INTERLEAVE);
  
  myservo.write(20);
  motory.step(300, BACKWARD, INTERLEAVE);
  motorx.step(400, BACKWARD, INTERLEAVE);
}

void Kletter()
{
   myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space 
  
   myservo.write(53);
  motorx.step(500, FORWARD, INTERLEAVE); 
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);
  motory.step(250, BACKWARD, INTERLEAVE);
  
  myservo.write(53);
  for (int i =0;i<250;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(1, FORWARD, INTERLEAVE);  
  }
 
 for (int i =0;i<250;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }  
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);  
}

void Mletter()
{
   myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  motorx.step(500, FORWARD, INTERLEAVE);
  
  myservo.write(53);
  motorx.step(500, BACKWARD, INTERLEAVE);
  
  for (int i =0;i<200;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  
  for (int i =0;i<200;i++)
  {
    motorx.step(1, BACKWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  
  motorx.step(500, FORWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);  
}

void Pletter()
{
   myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  motorx.step(500, FORWARD, INTERLEAVE);  
  
  myservo.write(53);
  motorx.step(500, BACKWARD, INTERLEAVE); 
  motory.step(200, BACKWARD, INTERLEAVE);
  motorx.step(300, FORWARD, INTERLEAVE);  
  motory.step(200, FORWARD, INTERLEAVE);
  
  myservo.write(20);
  motory.step(200, BACKWARD, INTERLEAVE);
  motorx.step(300, BACKWARD, INTERLEAVE);
}

void Qletter()
{
  myservo.write(20);
  motory.step(130, BACKWARD, INTERLEAVE); //space
  motorx.step(500, FORWARD, INTERLEAVE);

  myservo.write(53);
  motorx.step(500, BACKWARD, INTERLEAVE);
  motory.step(300, BACKWARD, INTERLEAVE);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(300, FORWARD, INTERLEAVE);
  motory.step(280, BACKWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(50, BACKWARD, INTERLEAVE);
  
  myservo.write(53);
  for(int i=0;i<130;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  
  myservo.write(20);
   motory.step(80, FORWARD, INTERLEAVE);
   motorx.step(580, BACKWARD, INTERLEAVE); 
}

void Rletter()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  motorx.step(500, FORWARD, INTERLEAVE);  
  
  myservo.write(53);
  motorx.step(500, BACKWARD, INTERLEAVE); 
  motory.step(200, BACKWARD, INTERLEAVE);
  motorx.step(300, FORWARD, INTERLEAVE);  
  motory.step(200, FORWARD, INTERLEAVE);
  
  for(int i=0;i<200;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);
  
}

void Sletter()
{
  myservo.write(20);
  motory.step(500, BACKWARD, INTERLEAVE); //space
  
  myservo.write(53);
  motory.step(400, FORWARD, INTERLEAVE);
  motorx.step(250, FORWARD, INTERLEAVE);
  motory.step(400, BACKWARD, INTERLEAVE);
  motorx.step(250, FORWARD, INTERLEAVE);
  motory.step(400, FORWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);
  motory.step(400, BACKWARD, INTERLEAVE); 
}

void Tletter()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
   
   myservo.write(53);
  motory.step(300, BACKWARD, INTERLEAVE);
  motory.step(150, FORWARD, INTERLEAVE);
  motorx.step(500, FORWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);
  motory.step(150, BACKWARD, INTERLEAVE);  
}

void Uletter()
{
  myservo.write(20);
  motory.step(130, BACKWARD, INTERLEAVE); //space

  myservo.write(53);
  motorx.step(500, FORWARD, INTERLEAVE);
  motory.step(300, BACKWARD, INTERLEAVE);
  motorx.step(500, BACKWARD, INTERLEAVE);
  
}

void Vletter()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
  myservo.write(53);
  for(int i=0;i<500;i++)
  {
    motorx.step(3, FORWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  for(int i=0;i<500;i++)
  {
    motorx.step(3, BACKWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
}

void Wletter()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
  myservo.write(53);
  for(int i=0;i<500;i++)
  {
    motorx.step(5, FORWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  
  for(int i=0;i<100;i++)
  {
    motorx.step(5, BACKWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  
   for(int i=0;i<100;i++)
  {
    motorx.step(5, FORWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  
   for(int i=0;i<500;i++)
  {
    motorx.step(5, BACKWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  
}

void Xletter()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
  myservo.write(53);
   for(int i=0;i<500;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(1, BACKWARD, INTERLEAVE);  
  }
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);

   myservo.write(53);
   for(int i=0;i<500;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(1, FORWARD, INTERLEAVE);  
  }
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);
  motory.step(500, BACKWARD, INTERLEAVE);  
}

void Yletter()
{
  myservo.write(20);
  motory.step(100, BACKWARD, INTERLEAVE); //space
  
  myservo.write(53);
  for(int i=0;i<150;i++)
  {
    motorx.step(1, FORWARD, INTERLEAVE);
    motory.step(3, BACKWARD, INTERLEAVE);  
  }
  for(int i=0;i<150;i++)
  {
    motorx.step(1, BACKWARD, INTERLEAVE);
    motory.step(3, BACKWARD, INTERLEAVE);  
  }
  
  myservo.write(20);
  motorx.step(150, FORWARD, INTERLEAVE);
  motory.step(450, FORWARD, INTERLEAVE); 
  
  myservo.write(53);
  motorx.step(350, FORWARD, INTERLEAVE);
  
  myservo.write(20);
  motorx.step(500, BACKWARD, INTERLEAVE);
  motory.step(450, BACKWARD, INTERLEAVE);
  
}

Credits

Fakhr El-deen Gamal

Fakhr El-deen Gamal

2 projects • 28 followers
I am an Electrical engineer student and i have passion on learning and working at embedded systems
Mohamed Sami

Mohamed Sami

1 project • 8 followers
Mechatronics Engineer

Comments