SCARA Robot Control System
A comprehensive control system for a 4-axis SCARA robot , integrating an Express.js backend API , Next.js frontend , and Arduino Mega firmware for precise motion control .
demo.mp4
This project enables remote control and automation of a SCARA robot , incorporating:
4 NEMA 17 Stepper Motors (Base rotation, Shoulder, Elbow, Z-axis)
Electromagnetic End Effector (Magnet-based gripping mechanism)
Web-based Control Interface (Next.js, TypeScript, Shadcn, TailwindCSS)
Backend API for Communication (Express.js, TypeScript)
Arduino Firmware for Hardware Control (Arduino Mega)
Custom 3D Printed Parts for structure and motion control
graph TD;
A["Next.js Frontend"]-->|HTTP Requests|B["Node.js Backend"];
B-->|Serial Communication|C["Arduino Mega"];
C-->|Control Signals|D["Stepper Motors"];
C-->|Control Signal|E["Magnet End Effector"];
B-->|Status Updates|A;
C-->|Status Updates|B;
Loading
Component
Details
Microcontroller
Arduino Mega 2560
Motors
4 x NEMA 17 Stepper Motors
Motor Drivers
A4988 Stepper Motor Driver
End Effector
Electromagnetic Gripper
Power Supply
12V DC for motors, 5V for electronics
Belts & Pulleys
GT2 Timing Belt (200mm, 300mm, 400mm)
Frame & Links
Custom 3D Printed PLA Components
1️⃣ Arduino Firmware (arduino_scara.ino)
Utilizes AccelStepper library for precise motor control
Processes serial commands for movement and magnet control
Implements safety features and position tracking
2️⃣ Express.js Backend API
Manages serial communication with the Arduino
Provides a RESTful API for robot control
Handles port management and command processing
Web-based control panel with real-time robot status
Interactive UI for manual and automated control
Responsive design for both desktop and mobile
⚙️ Installation and Setup
🔹 1. Clone the Repository
git clone https://github.com/ayuugoyal/scara.git
cd scara
Install the Arduino IDE
Install the AccelStepper library via the Library Manager
Connect the Arduino Mega to your computer
Upload arduino_scara.ino to the Arduino
🔹 3. Hardware Connections
Stepper Motors to Motor Drivers:
Axis
STEP Pin
DIR Pin
ENABLE Pin
Base Rotation
2
3
4
Shoulder
5
6
7
Elbow
8
9
10
Z-Axis
11
12
13
Magnet Connection → Pin 53
Power Supply → 12V for motors, 5V for logic circuits
cd backend
pnpm install
pnpm run dev # Development mode
pnpm start # Production mode
cd frontend
pnpm install
pnpm run dev
Port Management Endpoints
Method
Endpoint
Description
GET
/api/ports
List available serial ports
POST
/api/connect
Connect to a port ({"port": "/dev/ttyUSB0", "baudRate": 115200})
POST
/api/disconnect
Disconnect the current port
GET
/api/status
Get connection status
Method
Endpoint
Description
POST
/api/command
Send a movement command ({"command": "M0 200 1000"})
POST
/api/magnet
Control the magnet ({"state": true} or {"state": false})
Command
Description
M{motor_index} {position} {speed}
Move motor to specific position
M,1
Turn on electromagnet
M,0
Turn off electromagnet
scara/
├── arduino_scara/ # Arduino firmware
│ └── arduino_scara.ino # Main Arduino sketch
├── backend/ # Express.js backend
│ ├── src/
│ │ ├── app.ts # Main Express application
│ │ ├── controllers/ # API request handlers
│ │ ├── routes/ # API route definitions
│ │ ├── services/ # Serial communication service
│ │ └── types/ # Type definitions
│ └── package.json # Backend dependencies
├── frontend/ # Next.js frontend
│ ├── app/ # Next.js app directory
│ │ ├── api/ # API routes
│ │ └── page.tsx # Main page component
│ ├── components/ # UI Components
│ └── package.json # Frontend dependencies
└── README.md # Documentation