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("----...
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 ...
Comments
Post a Comment