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
HAL Sensors Uni- and Bipolar Hall IC Switches for Magnetic Field Applications TLE 4905L This hall sensor is an open collector sensor, So how to get the output from this sensor is you need to add a resistor RL 1.2k ohm as a circuit below. Application Circuit from Datasheet Signal capture from oscilloscope Sample Code: #include <TimerThree.h> //Speed Sensors #define speed_r 2 #define speed_l 3 #define length_4pulse 80 //millimeter volatile int speed_pulse = 0; volatile float current_speed = 0; void setup() { // put your setup code here, to run once: Serial.begin(115200); //Speed Detect pinMode(speed_r, INPUT); pinMode(speed_l, INPUT); attachInterrupt(digitalPinToInterrupt(speed_r), speed_count, RISING); Timer3.initialize(100000); // initialize timer3, and set a 1/10 second period Timer3.attachInterrupt(speed_calculate); } void loop() { // put your main code here, to run repeatedly: //Correct Data Serial.println("----...
Comments
Post a Comment