Before we begin assembling our watering system, let’s take some rest and talk about the most frequent errors we can encounter when we work in the Arduino development environment. I am going to take our automate template, which was initially incomplete, and will try to compile it. We are immediately getting a lot of error messages. I want you to stop fearing this console where these messages are output and start reading what is actually written there. It would surely be useful if you spoke some English, but if not, you can simply remember what the most common error messages look
like. The messages keep telling us that “WebRequest”, “CheckClimate”, “CheckWater”, “Watering”, “Alarm”, and “SendPage” – all these functions were not declared in this scope. Here is this message. You may get a similar message concerning functions or variables. Thus, if you don’t define a function, the compiler will punish you for it. If you have invented this function by yourself, make sure you check how
you defined it, i.e. if you wrote a definition. If you are using a library function, make sure you’ve connected the library, and placed the files in the library in the right places. Arduino usually stores them in the “My documents” folder in Arduino
Libraries. Besides, you might be getting this error message if you are trying to call an
existing function, but you are doing it incorrectly. Check if you’ve written the name of the function correctly. The same happens with variables. However, you’ll also need to take their scope into consideration. Remember, we were talking about global and local variables? If you are trying to call from a function a local variable declared in another function, an error message will appear. The same will happen if you’ve forgotten to declare a variable and you are trying to refer to it. What other frequent errors can we encounter? I’ll leave this automate sketch alone for a moment in order not to spoil it
somehow. And I’ll take our standard Blink sketch [PAUSE] and will disfigure it a tiny bit. Like, I can forget to put the curly bracket, and then try and compile the sketch. An error message appears again. If we throw a glance at the sketch, we can see at once that one curly bracket is missing. Please, make sure you check that your curly brackets are always
paired. I’ll put this bracket back, but once again I recommend that you format your code attentively, i.e. after the opening curly bracket, you need to add Tab space, and with the closing bracket, the same happens but in the opposite manner. Thus, it’ll be easier for you to see if the two brackets are paired with
each other. I’m putting back the bracket, but let’s imagine that I forget the
semi-colon. The message explicitly shows us that a semi-colon before the curly bracket is necessary. When you call a function, you might see an error message concerning unpaired parentheses. If we are transmitting the calling of another function as a parameter, we need to first close the parentheses of the internal function, which is transmitted with a parameter, and then the parentheses of the function
to which our internal function is
transmitted. Don’t forget about paired parentheses. Besides, when you are calling a function, you need to transmit to it as many parameters as it is expecting. Well, I think, this is quite obvious. you may also get a message that a different number of parameters was expected. I often get such errors from the compiler, but sometimes there occurs an error which the compiler ignores, since it thinks that nothing looks wrong there. This happens when you confuse “=” with “= =”. “=” is the assignment operator that places whatever there is to the right of it, to the section which is to the left of it. “= =” is the boolean comparisons operator, which checks if the
values are equal. We may often forget in the if-clause about the double equals sign and write, for instance, if (a = b). In this case, comparison will not take place, and the result of this action will not be boolean “1” if a=b, but “а” will equal “b” in any case. Thus, you will assign the “b” value to the “a” variable. You mustn’t forget about that either. Finally, when we work with Arduino, apart from program code errors we might also have errors concerning the upload of
the sketch to the board. The most frequent reason for errors is when we forger to connect the wire. You might also forget to check whether you’ve chosen the right board model or marked the port which appears when we connect the board. If it all seems fine, there may occur some situations when
somewhere in the circuit, a short-circuit failure happens, and the voltage regulator cuts off the connection with the computer in order not to mess up
your USB. In that case, remove all your expansion cards, turn off all the components and try to upload the sketch. If nothing happens, look for the short-circuit failure in your
circuit. Last but not least, when you forget to shut down the Port Monitor or the analog signal visualizer, you won’t be able to upload a new sketch either. So you will need to make
sure you shut them down. Naturally, these are not all the probable errors that we might experience, but we have definitely covered the better part of them. I hope that they won’t bother you too much when you practice.