Lets continue talking about Arduino IDE. Arduino is a powerful solution for newbies. Let us discuss about a simple program. First open Arduino IDE and follow the path given below
File > Examples > Basics > DigitalReadSerial
It should open in a new program window as shown below
In the starting of the program we can see a short description about the program followed by /* and */ indicates that it is a multi line comment which not considered during the execution of the program . Also following that you can find a description followed by // which indicates they are single line comments. You can use these techniques to add important comments to your program.
In the beginning of the program you can see that
int pushButton = 2;
By closely observing the code you can find that the int is highlighted which means it is a function. int means that the function is an integer. Following that the word pushButton is a variable. The variable is just a word which holds the data provided by the = sign. You can set any name to a variable. Here = 2 indicates it id digital pin 2 on the Arduino board. At the end of each statement it ends with ; which means that you are done with that function. You should provide ; to ending of each function.
Following that we have already discussed that the functions void setup() and void loop() are essential in writing the program code. void means that that function do not return any information back to the program. The function setup() run only once in the program. But in the case of loop() which runs over and over in the program.
The delay() function indicates the rate or speed of the process. It is expressed in milliseconds. For
example if we want to blink an led every second, after we turn it on we can place
a delay(1000) which will make the processor sit there and do nothing for a second
(1000 milliseconds). Delay is also useful in debugging and general flow control.
No comments:
Post a Comment
keep supporting funwithelectronian.blogspot.com