Flow Chart: Self Drifting Cars Self Drifting Cars Flow Chart Self Drifting Cars Flow Chart as shown in figure above, start with analog infrared sensor to detect distance in front direction of the cars, accelerometer received acceleration of the cars, ultrasonic sensor received distance between the cars and the wall to calculate offset angle by using PID controller to steering car direction and to avoid collision from the wall, then we can limit speed of the cars by using HAL-sensor with PID controller then send command to steering and speeding the cars and then the cars send back about current data to raspberry pi
VNH2SP30 Motor Driver Carrier MD01B VNH2SP30 Motor Driver Carrier MD01B connector description This module used for drive a DC motor. Pin that needs to connected is PWM, IN A, IN B, OUT A, OUT B, +5 V, and GND. Sample code: #define InA_PIN 4 //Yellow #define InB_PIN 5 //Blue #define PWM_PIN 3 //Green //INA 1 INB 0 clockwise FORWARD //INA 0 INB 1 counterclockwise REVERSE void setup() { // put your setup code here, to run once: pinMode(InA_PIN, OUTPUT); pinMode(InB_PIN, OUTPUT); pinMode(PWM_PIN, OUTPUT); analogWrite(PWM_PIN, 0); digitalWrite(InA_PIN, HIGH); digitalWrite(InB_PIN, LOW); } void loop() { // put your main code here, to run repeatedly: digitalWrite(InA_PIN, HIGH); digitalWrite(InB_PIN, LOW); analogWrite(PWM_PIN, 255); delay(2000); digitalWrite(InA_PIN, LOW); digitalWrite(InB_PIN, HIGH); analogWrite(PWM_PIN, 127); delay(5000); } If IN A is high and IN B is low then the motor will drive forward. But if IN A is low and IN ...
Sharp 2Y0A21 F 03 Distance Measuring Sensor Unit Sharp 2Y0A21 F 03 This sensor can measure a distance from 10 to 80 cm with analog output. The range of output voltage is defined as a graph below. Voltage output from 0.4 to 2.25 V (80 to 10 cm) Sample Code: void setup() { // put your setup code here, to run once: pinMode(A6, INPUT); pinMode(A7, INPUT); Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: Serial.println(analogRead(A6)); delay(1); Serial.println(analogRead(A7)); delay(1000); } Because the output of this sensor in analog output, So we can read data easily by using ADC. (analogRead() function in arduino) In this code, we read from 2 sharp sensors and print output to a serial port. Reference: Datasheet
Comments
Post a Comment