Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interfacing Ultrasonic distance sensor with arduino

Status
Not open for further replies.

kodi.sudar

Member level 5
Joined
Dec 21, 2009
Messages
92
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
india
Activity points
1,849
hi i am using ultrasonic distance sensor from sunrom
**broken link removed**
i tried interfacing with Arduino uno serially but when i monitor the sensor data in serial monitor window i dont find any data in that , here is my code
Code:
char sensorData[10];
int index = 0;
void setup()
{
  Serial.begin(9600);
}
void loop()
{
   // While there is data, and we have read less than 9 characters
   while(Serial.available() > 0 && index < 9)
   {
      char inChar = Serial.read(); // Read a character
      sensorData[index] = inChar; // Store it
      index++;
      sensorData[index] = '\0'; // Null terminate the string
   }

  // Serial.print("Sensor data: ");
   Serial.println(sensorData);

   // Do whatever else you need to do to parse the string and use the data

   index = 0;
}
can any body help me sort out the problem
 

Try with modified code
char sensorData[10];
int index = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
// While there is data, and we have read less than 9 characters
while(index < 9)
{
if(Serial.available())
{
char inChar = Serial.read(); // Read a character
sensorData[index] = inChar; // Store it
index++;
sensorData[index] = '\0'; // Null terminate the string
}
}

// Serial.print("Sensor data: ");
Serial.println(sensorData);

// Do whatever else you need to do to parse the string and use the data

index = 0;
}
 

the fails to work, it is not displaying any thing in the serial window.

- - - Updated - - -

the circuit is not a big one, i have connected the sensor output ( serial, 9600 baud rate) to the Rx pin (pin 1) in arduino board, 5v supply and ground
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top