Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Semi-Autonomous GPS-Navigated Wheelchair with Obstacle Avoidance and Joystick Control

View and Edit Project In Cirkit DesignerImage of Semi-Autonomous GPS-Navigated Wheelchair with Obstacle Avoidance and Joystick Control

Circuit Documentation

Summary

The circuit in question appears to be designed for a semi-autonomous wheelchair addon. It includes a GPS module for navigation, ultrasonic sensors for obstacle detection, a joystick for manual control, a motor driver for controlling the wheelchair's motors, and an Arduino Mega 2560 microcontroller as the central processing unit. The circuit also includes a step-down module to regulate voltage, an emergency stop mechanism, batteries for power supply, a buzzer for alerts, a push button board for additional controls, and an LCD display for user interface.

Component List

GPS NEO 6M

HC-SR04 Ultrasonic Sensor (x3)

24v e-bike DC Motor (x2)

MDDS30 A Cytron Motor Driver

Step Down Module

Adafruit Mini Analog Thumbstick

Arduino Mega 2560

12V 200Ah Battery (x4)

Emergency STOP

Buzzer

8 Push Button Board PCB

LCD Display 16x4 I2C

30A Motor Controller

DC Motor (x2)

Wiring Details

GPS NEO 6M

HC-SR04 Ultrasonic Sensor (Front)

HC-SR04 Ultrasonic Sensor (Left)

HC-SR04 Ultrasonic Sensor (Right)

24v e-bike DC Motor (Left)

24v e-bike DC Motor (Right)

MDDS30 A Cytron Motor Driver

Step Down Module

Adafruit Mini Analog Thumbstick

Arduino Mega 2560

12V 200Ah Battery

Emergency STOP

Buzzer

8 Push Button Board PCB

LCD Display 16x4 I2C

30A Motor Controller

DC Motor (x2)

Documented Code

Arduino Mega 2560 Code

/*
 * Semi-Autonomous Wheelchair Addon
 * This code controls a wheelchair using 2 motors, 3 ultrasonic sensors, a GPS
 * module, and a joystick. The wheelchair avoids obstacles and navigates to a
 * set location using GPS. The joystick allows manual control. Safety features
 * include sensor checks before operation and interrupt-based emergency stop.
 */

#include <SoftwareSerial.h>
#include <TinyGPS++.h>

#define TRIG_LEFT 22
#define ECHO_LEFT 23
#define TRIG_RIGHT 24
#define ECHO_RIGHT 25
#define TRIG_FRONT 26
#define ECHO_FRONT 27
#define MOTOR_LEFT_SIG1 2
#define MOTOR_LEFT_SIG2 3
#define MOTOR_RIGHT_SIG1 4
#define MOTOR_RIGHT_SIG2 5
#define JOYSTICK_X A0
#define JOYSTICK_Y A2
#define GPS_RX 19
#define GPS_TX 18

TinyGPSPlus gps;
SoftwareSerial gpsSerial(GPS_RX, GPS_TX);

const double targetLat = 0.0; // Set target latitude
const double targetLon = 0.0; // Set target longitude

volatile bool obstacleDetected = false;

void setup() {
  pinMode(TRIG_LEFT, OUTPUT);
  pinMode(ECHO_LEFT, INPUT);
  pinMode(TRIG_RIGHT, OUTPUT);
  pinMode(ECHO_RIGHT, INPUT);
  pinMode(TRIG_FRONT, OUTPUT);
  pinMode(ECHO_FRONT, INPUT);
  pinMode(MOTOR_LEFT_SIG1, OUTPUT);
  pinMode(MOTOR_LEFT_SIG2, OUTPUT);
  pinMode(MOTOR_RIGHT_SIG1, OUTPUT);
  pinMode(MOTOR_RIGHT_SIG2, OUTPUT);
  pinMode(JOYSTICK_X, INPUT);
  pinMode(JOYSTICK_Y, INPUT);
  gpsSerial.begin(9600);
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(ECHO_FRONT), emergencyStop, CHANGE);
  attachInterrupt(digitalPinToInterrupt(ECHO_LEFT), obstacleInterrupt, CHANGE);
  attachInterrupt(digitalPinToInterrupt(ECHO_RIGHT), obstacleInterrupt, CHANGE);
}

void emergencyStop() {
  stopMoving();
  while (true) {
    if (digitalRead(ECHO_FRONT) == LOW) break;
  }
}

void obstacleInterrupt() {
  obstacleDetected = true;
}

long readUltrasonicDistance(int trigPin, int echoPin) {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  return pulseIn(echoPin, HIGH) / 58.2;
}

void moveForward(int speed) {
  analogWrite(MOTOR_LEFT_SIG1, speed);
  analogWrite(MOTOR_LEFT_SIG2, 0);
  analogWrite(MOTOR_RIGHT_SIG1, speed);
  analogWrite(MOTOR_RIGHT_SIG2, 0);
}

void moveBackward(int speed) {
  analogWrite(MOTOR_LEFT_SIG1, 0);
  analogWrite(MOTOR_LEFT_SIG2, speed);
  analogWrite(MOTOR_RIGHT_SIG1, 0);
  analogWrite(MOTOR_RIGHT_SIG