Go Down

Topic: ABOUT PROGRAM (Read 852 times) previous topic - next topic

UKHeliBob

Code: [Select]
pinMode(11,OUTPUT); // buzzer in digital pin 11 }
The } is still commented out so setup() does not end here.

Code: [Select]
for(int x=0;x
What do you want this for loop to do ?  Whatever it is it is written wrongly at the moment.

For loops are one of the fundamental programming structures in C (and most programming languages) so you would be wise to read about them and understand how they work.

Dare I suggest that you read this before posting a programming question and follow the advice it contains about posting code here.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

sterretje

#16
Feb 04, 2017, 05:02 pm Last Edit: Feb 04, 2017, 05:04 pm by sterretje
I suggest that you start with a book on C and learn the basics before continuing.

And please edit your reply #11. Currently it's impossible to determine if you made stupid mistakes or that something else went wrong.

type [code] before the code
type [/code] after the code

To help a you a little on the way
Code: [Select]
void setup()
{

  Serial.begin(9600); // initializing Serial monitor pinMode(IRemitter,OUTPUT); // IR emitter LED on digital pin 2 digitalWrite(IRemitter,LOW);// setup IR LED as off

  pinMode(11, OUTPUT); // buzzer in digital pin 11 }
                                                   ^
                                                   ^
                                              this } needs to move to the next line to 'close' the setup()

Same for the } at the end of this line
Code: [Select]
distance = readIR(5); // calling the function that will read the distance and passing the "accuracy" to it Serial.println(distance); // writing the read value on Serial monitor // buzzer(); // uncomment to activate the buzzer function }


If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Go Up