Hi i am working on a project of obstacle avoidance using SRF04 sensor i need 10 different reading inside a loop.
but am getting error invalid type int[int] array subscript i have bolded the portion where am facing this problem.
thanks.
void loop()
{
myservo.write(pos);
delay(100);
for(pos = 105; pos > 75; pos -=5) // goes from 105 degrees to 75 degrees
{ // in steps of 5 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
digitalWrite(trigPin, LOW); // Set the trigger pin to low for 2uS
delayMicroseconds(2);
digitalWrite(trigPin, HIGH); // Send a 10uS high to trigger ranging
delayMicroseconds(10);
digitalWrite(trigPin, LOW); // Send pin low again
int distance= pulseIn(echoPin, HIGH); // Read in times pulse
distance=distance/58; // Calculate distance from time of pulse
int DISTANCE;
** for (int a = 0; a < 6; a = a + 1)**
{
** DISTANCE[a]= distance; /// i want 5 reading of angle 105 , 100, 95, 90, 85, 80,75 to be stored in DISTANCE1, DISTANCE2 RESPECTIVELY**
** }**
delay(25); // Wait 50mS before next ranging
Serial.print("ANGLE ");
Serial.print(pos);
Serial.print(" = ");
Serial.println(distance);
}