SRF10 Ultrasonic sensors SRF10 connector description This module used I2C as a protocol to communication with MCU. This module support to use with more than one module in system up to 16 module. We can set ID address for each module before integrated to the system, About how to change ID address click here . For distance to measure this module can measure from 6 cm to 6 m. Sample code: #include <Wire.h> //For Ultrasonic //ADDRESS #define Front_Left 112 #define Front_Right 114 #define CMD 0x00 #define Read_inch 0x50 #define Read_cen 0x51 #define Read_micro_sec 0x52 #define Read_pointer 0x02 void setup() { // put your setup code here, to run once: Serial.begin(115200); Wire.begin(); } void loop() { // put your main code here, to run repeatedly: //Correct Data Serial.println("----"); read_distance_ultrasonic(Front_Left); delay(75); read_distance_ultrasonic(Front_Right); delay(75); } int read_distance_ultrasonic(int addr){ i...
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
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
Comments
Post a Comment