SHARE
TWEET

arduino OsciBouncer

davidjongen Nov 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int trigPin1=5;
  2. int echoPin1=6;
  3.  
  4. #include <SoftwareSerial.h>
  5. SoftwareSerial EEBlue(10, 11); // RX | TX
  6.  
  7.  
  8. void setup() {
  9.   Serial.begin (9600);
  10.   pinMode(trigPin1, OUTPUT);
  11.   pinMode(echoPin1, INPUT);
  12.   Serial.begin(9600);
  13.   EEBlue.begin(9600);  //Default Baud for comm, it may be different for your Module.
  14.   Serial.println("The bluetooth gates are open.\n Connect to HC-05 from any other bluetooth device with 1234 as pairing key!.");
  15.  
  16.  
  17.  
  18. }
  19.  
  20. void loop() {
  21.   long duration1, distance1;
  22.   digitalWrite(trigPin1, LOW);  // Added this line
  23.   delayMicroseconds(2); // Added this line
  24.   digitalWrite(trigPin1, HIGH);
  25.   delayMicroseconds(10); // Added this line
  26.   digitalWrite(trigPin1, LOW);
  27.   duration1 = pulseIn(echoPin1, HIGH);
  28.   distance1 = duration1*0.034/2;
  29.  
  30.   // Feed any data from bluetooth to Terminal.
  31.   if (EEBlue.available())
  32.     Serial.write(EEBlue.read());
  33.  
  34.   // Feed all data from termial to bluetooth
  35.   if (Serial.available())
  36.     EEBlue.write(Serial.read());
  37.  
  38.  
  39.     Serial.println(distance1);
  40.  
  41.  
  42.  
  43.  
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top