US-100 Ultrasonic Distance Sensor Module

From air
Jump to: navigation, search
Ultrasonic Sensor US-100 on MSP430 Launchpad G2

https://www.bananarobotics.com/shop/US-100-Ultrasonic-Distance-Sensor-Module

Capteur de distance ultrason supportant 2 modes : GPIO et Série (il faut retirer le jumper pour le mode série)

Il est compatible avec les programmes pour le capteur HR-SC04.


This sensor can be used with both 3.3V (MSP430, STM32 Discovery) and 5V (Arduino, STM32 Nucleo) microcontrollers and only consumes 2mA when idle.

Using the US-100 Ultrasonic Distance Sensor Module Connect the VCC and GND pins to a 2.4V-5.5V power supply. The usage of the other pins depends on the operating mode selected. Select the operating mode of the US-100 Ultrasonic Distance Sensor by using the jumper on the back of the module. When the jumper is present, the sensor outputs the distance as binary serial data, otherwise the sensor outputs a single pulse that has a width which represents the distance measured.


Specifications

MBed


TI' MSP430 Launchpad

/*
Simple Test of Ultrasonic Sensor US-100 on MSP430 Launchpad G2.

US-100 from https://www.bananarobotics.com/shop/US-100-Ultrasonic-Distance-Sensor-Module

Source inspired from http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/
*/

// set pin numbers:
const int trigPin = P1_6;
const int echoPin =  P1_7; 

void setup() {
  Serial.begin(9600); 
  Serial.println("Ultrasonic sensor US-100 test"); 
  pinMode(trigPin, OUTPUT);      
  pinMode(echoPin, INPUT);     
}

void loop(){
  long duration, distance;
  digitalWrite(trigPin, LOW); // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); - Removed this line
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
   duration = pulseIn(echoPin, HIGH);
   distance = (duration/2) / 29.1;

  Serial.print(distance);
  Serial.println(" cm");
  delay(500);
}