Answer to Question #33312 in C++ for sandar

Question #33312
Hello this is my program.Now I am using this program for 6 ultrasonic sensor and then this program for pin 9. I don't know how to array for 6 ultrasonic sensor.please help me.thanks!

int ultraSoundpin = 9;
unsigned long ultrasoundDuration = 0;


void setup() {
Serial.begin(9600);
}

void loop() {

// switch pin to output
pinMode(ultraSoundpin0, OUTPUT);

// send a low, wait 2 microseconds, send a high then wait 10 microseconds
digitalWrite(ultraSoundpin0, LOW);
delayMicroseconds(2);
digitalWrite(ultraSoundpin0, HIGH);
delayMicroseconds(10);
digitalWrite(ultraSoundpin0, LOW);

// switch pin to input
pinMode(ultraSoundpin0, INPUT);

// wait for a pulse to come in as high
ultrasoundDuration0 = pulseIn(ultraSoundpin0, HIGH);


// output
Serial.print(ultrasoundDuration0/58, DEC);
Serial.print(" cm");
Serial.println();
delay(2000);


}
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS