This project is for my plan, a robotic car that can detect schools and avoid obstacles that the AI will automatically crash it into or block.
Materials for this project
Arduino Uno
shield
2 wheel car scene
server
Obviously
:
IDE
Motor Shield Library
New flat warehouse
Step 1
Make your first Arduino robot hub. The base of the Arduino, two, a front seat, some and.
Step 2
On the motor there is a thick black wire and a red wire.
Step 3
Install the front wheel.
Step 4
After the road, there is a connection where the other end is connected to the holder. Cut the side wire position of the battery and then to the battery holder. Our house is ready to the battery holder. .
Step 5
The next step is to connect the motor to the monitored M1.
Step 6
Moving on to the motors. The shield provides for motors and servos to make our project easier. The motors require and this shield can provide up to 600mA to each motor, that's why it solders 4 wires to the motors. Then the wires where the sensors connect will solder one V, one to the ground, one to the 5 that connects to the model. 5 and the last one to the case. To the analog map 4.
Step 7
Next, attach the motor cover to the motor. On one side, mount the Arduino to the chassis. Using the connector, attach our antenna mount and antenna to the motor and attach them both to the robot. I attached the servo motors to the chassis using connector glue.
Supersonic sensor
To configure the ultrasonic sensor, follow these steps:
The first grounding point is reached via the overspeed connection line of the connection line 5 steps
ECHO sensor to ground wire connected to ground terminal 1 step ago 5, TRIG ground wire connected to our connection 4.
The next step of the second
Connect, connect the wire of our switch to the motor cover, connect it to this external power connector. 2 The red wire connector of the black switch will turn our switch on, and we can turn the switch on. See it lights up, the Arduino is receiving power from the battery.
Step 3
Finally we connect the servo motor to the servo_2 slot. The darker color on the right is red in the middle and the darker color on the left is orange.
software
The project code uses three libraries. Two of them are required to compile the program. The first is the motor shield driver from afruit. The second library is the Newng library for the supersonic sensor. You can use the links for both libraries here:
Arduino IDE code:
#include
#include
#include
#define TRIG_PIN A4
#define ECHO_PIN A5
#define MAX_DISTANCE_POSSIBLE 1000
#define MAX_SPEED 150 //
#define MOTORS_CALIBRATION_OFFSET 3
#define COLL_DIST 20
#define TURN_DIST COLL_DIST+10
NewPing声纳(TRIG_PIN,ECHO_PIN,MAX_DISTANCE_POSSIBLE);
AF_DCMotor leftMotor(4, MOTOR12_8KHZ);
AF_DCMotor rightMotor(3, MOTOR12_8KHZ);
Servo neck controller ServoMotor;
int position = 0;
int maxDist = 0;
int maxAngle = 0;
int maxRight = 0;
int maxLeft = 0;
int maxFront = 0
;
int curDist = 0; int
motorSet = "";
int speedSet = 0;
void setup() {
NeckControllerServo.append(10);
NeckControllerServo.wri(90);
delay(2000);
checkPath();
motorSet = "forward";
NeckControllerServo.write(90);
moveForward();
}
void loop() {
checkForward();
checkPath();
}
void checkPath() {
int curLeft = 0;
int curRight = 0;
int
curDist = 0;
neckControllerServoMotor.write(144);
delay(120);
for(pos = 144; pos >= 36; pos -= 18)
{
eckControlleervoMotor.write(pos);
delay(90);
checkForward();
curDist = readPing();
(curDist < COLL_DIST) {
checkCourse();
break;
}
if (curDist < TURN_DIST) {
changePath();
}
if (curDist > curDist) {maxAngle = pos;}
if (pos > 90 && curDist > curLeft) { curLeft = curDist;}
if (pos == 90 && curDist > curFront) curFront = curDist;}
if (pos < 90 && curDist > curRight) {curRight = curDist;}
}
maxLeft = curLeft;
maxRight = curRight;
maximum frontier = current frontier;
}
void setCourse() {
if (maxAngle < 90) {turnRight();}
if (maxAngle > 90) {turnLeft();}
maxLeft = 0;
maxRight = 0; maxLeft
= 0;
}
void checkCourse() {
moveBackward();
delay(500);
moveStop();
setCourse();
}
void changePath() {
if (pos < 90) {lookLeft();}
if (pos > 90) {lookRight();}
}
int readPing() {
delay(70);
unsigned int uS = sonar.ping();
int cm = uS/US_ROUNDTRIP_CM;
return cm;
}
void checkForward() { if (motorSet=="FORWARD") {leftMotor.run(FORWARD); rightMotor.run(FORWARD); } }
void checkBackward() { if (motorSet=="BACKWARD") {leftMotor.run(BACKWARD); rightMotor.run(BACKWARD); } }
Invalid moveStop() {leftMotor.run(RELEASE); rightMotor.run(RELEASE);}
Invalid moveForward() {
motorSet = "FORWARD";
leftMotor.run(FORWARD);
rightMotor.run(FORWARD);
for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2)
{
leftMotor.setSpeed(speedSet+MOTORS_CALIBRATION_OFFSET);
rightMotor.setSpeed(speedSet);
delay(5);
}
}
Invalid moveBackward() {
motorSet = "BACKWARD";
leftMotor.run(BACKWARD);
rightMotor.run(BACKWARD);
for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2)
{
leftMotor.setSpeed(speedSet+MOTORS_CALIBRATION_OFFSET);
rightMotor.setSpeed(speedSet);
delay(5);
}
}
void turnRight() {
motorSet = "RIGHT";
leftMotor.run(FORWARD);
rightMotor.run(BACKWARD);
delay(400);
motorSet = "Forward";
leftMotor.run(FORWARD);
rightMotor.run(FORWARD);
}
void turnLeft() {
motorSet = "LEFT";
leftMotor.run(BACKWARD);
rightMotor.run(FORWARD);
delay(400);
motorSet = "FORWARD";
leftMotor.run(FORWARD);
rightMotor.run(FORWARD);
}
void lookRight() {rightMotor.run(BACKWARD); delay(400);rightMotor.run(FORWARD);}
void lookLeft() {leftMotor.run(BACKWARD); delay(400);leftMotor.run(FORWARD);}
Previous article:Industrial robot remote monitoring solution based on industrial router
Next article:Comau launches RACER-5 SE: a cleanroom-grade waterproof and anti-fouling high-speed industrial robot
- Popular Resources
- Popular amplifiers
- Using IMU to enhance robot positioning: a fundamental technology for accurate navigation
- Researchers develop self-learning robot that can clean washbasins like humans
- Universal Robots launches UR AI Accelerator to inject new AI power into collaborative robots
- The first batch of national standards for embodied intelligence of humanoid robots were released: divided into 4 levels according to limb movement, upper limb operation, etc.
- New chapter in payload: Universal Robots’ new generation UR20 and UR30 have upgraded performance
- Humanoid robots drive the demand for frameless torque motors, and manufacturers are actively deploying
- MiR Launches New Fleet Management Software MiR Fleet Enterprise, Setting New Standards in Scalability and Cybersecurity for Autonomous Mobile Robots
- Nidec Drive Technology produces harmonic reducers for the first time in China, growing together with the Chinese robotics industry
- DC motor driver chip, low voltage, high current, single full-bridge driver - Ruimeng MS31211
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- MSP430 single chip microcomputer makes intelligent digital multimeter circuit diagram + program
- program
- Innovative power supply questions - Analysis of 2019 National Power Equipment A Question
- EEWORLD University Hall----Using MATLAB for FPGA Design
- EEWORLD University Hall----Live Replay: Secure Boot of Microprocessors
- The crystal pins are black, what should I do?
- Revealed: Tektronix's first oscilloscope for you is now on the market
- What microcontroller can be connected to the network via optical fiber using the CAN bus?
- Some problems with nested make
- [SAMR21 new gameplay] 30. Pin definition