Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:programming_fundamentals_rtu:building_your_first_project [2018/01/12 14:03] Agrisniken:iot-open:programming_fundamentals_rtu:building_your_first_project [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 135: Line 135:
 } }
 </code> </code>
 +
 +In the source code of program following things can be seen:
 +  - It it defined that the LED_BUILTIN is set to be the output of the program. In this example sketch, the output periodically sends the specific signal that is in the level of the logical 1 (+5V) and 0 (0V). Sending output signal to the built-in LED, the LED is periodically turned on and off.
 +  - Continuous executable function //loop()// is created that allocates 1 second (1000 ms) of time to each level of signal. It is done by pausing the execution of program. While the program is not changing the states of the inputs/outputs, they remain unchanged. In this way, when the +5 V signal is sent to the LED output and the program execution is paused, the LED will continue to shine until the level of the output will be set to 0 V.
 +  - The last row indicates that the program will be paused for a 1 second also when the output level is set to be 0 V. In this way the period of LED on and off are equal. After executing this program, the program returns to the first line of the //loop()// function and the execution starts from the beginning.
  
  
 ===== Hello World ===== ===== Hello World =====
 +"//Hello World//" program is the simplest program, because it simply outputs the text to the screen.
 +Here is the //Hello World// program for Arduino that outputs the text on the Serial Monitor each second:
 +<code c>
 +void setup() {
 +  Serial.begin(9600); //establishes the connection with the serial port
 +}
 +
 +void loop() {
 +  Serial.println("Hello World"); //prints out the line with the text
 +  delay(1000);                   //pause for 1 second
 +}
 +</code>
 +
 +Serial Monitor can be found following the path: //Tools->Serial Monitor//.
 +
 +In the code can be seen that the //setup()// function contains the following command:
 +<code c>
 +Serial.begin(9600);
 +</code>
 +This statement opens the serial port at the initialization of the program so that the Serial Monitor can be used for outputting text or values on the screen.
 +
 +For printing out text the following command is used:
 +<code c>
 +Serial.println("Hello World");
 +</code>
 +
 +**Check yourself**
 +
 +1. How to attach any library to a sketch?
 +
 +2. What command expressions are not usually separate by semicolon?
 +
 +3. How to establish a serial communication between devices?
 +
 +4. How does delay() command works?
 +
 +*Stops LED blinking specified number of milliseconds
 +
 +*Stops program execution for a specified number of seconds
  
 +*Stops program execution for a specified number of milliseconds
  
en/iot-open/programming_fundamentals_rtu/building_your_first_project.1515765784.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0