<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
		<id>https://wiki.ardumower.de/index.php?action=history&amp;feed=atom&amp;title=Arduino_crash_course_ru</id>
		<title>Arduino crash course ru - Versionsgeschichte</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.ardumower.de/index.php?action=history&amp;feed=atom&amp;title=Arduino_crash_course_ru"/>
		<link rel="alternate" type="text/html" href="https://wiki.ardumower.de/index.php?title=Arduino_crash_course_ru&amp;action=history"/>
		<updated>2026-10-09T22:57:21Z</updated>
		<subtitle>Versionsgeschichte dieser Seite in www.wiki.ardumower.de</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>https://wiki.ardumower.de/index.php?title=Arduino_crash_course_ru&amp;diff=2670&amp;oldid=prev</id>
		<title>Unlogic: Die Seite wurde neu angelegt: „ You never had to with programming yet? This page shows you the very basic concepts of programming the Arduino. After reading, you will be able to develop your…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.ardumower.de/index.php?title=Arduino_crash_course_ru&amp;diff=2670&amp;oldid=prev"/>
				<updated>2015-08-22T19:25:01Z</updated>
		
		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „ You never had to with programming yet? This page shows you the very basic concepts of programming the Arduino. After reading, you will be able to develop your…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
You never had to with programming yet? This page shows you the very basic concepts of programming the Arduino. After reading, you will be able to develop your own Arduino programs and to understand the Ardumower code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Your first program =&lt;br /&gt;
&lt;br /&gt;
This will make the onboard Arduino LED to blink (by toggling Arduino pin 13 between 5V and 0V):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 // This is run only once after the Arduino starts. The command 'pinMode' configures the Arduino LED pin 13&lt;br /&gt;
 void setup() {&lt;br /&gt;
   pinMode(13, OUTPUT);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 // This will be run over and over (so forever). It's the main loop of the program.&lt;br /&gt;
 void loop() {&lt;br /&gt;
   digitalWrite(13, HIGH);    // set pin 13 to 5V/HIGH&lt;br /&gt;
   delay(1000);               // wait 1000 milliseconds (=1 second)&lt;br /&gt;
   digitalWrite(13, LOW);     // set pin 13 to 0V/GND/LOW&lt;br /&gt;
   delay(1000);               // wait 1000 milliseconds (=1 second)&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run this code in your Arduino IDE and see what happens with your onboard Arduino LED. Then try to adjust the example so that the LED blinks more quickly!&lt;br /&gt;
&lt;br /&gt;
= Expressions =&lt;br /&gt;
&lt;br /&gt;
Everything that can be calculated is an expression. Expressions are used to compute things. We will use expressions later for variables or functions calls.&lt;br /&gt;
&lt;br /&gt;
Examples for expressions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 13               =&amp;gt; can be computed to 13 (it's simple right?)&lt;br /&gt;
 2 * 13           =&amp;gt; can be computed to 26&lt;br /&gt;
 42 - 9 * 100     =&amp;gt; can be computed as everything is known to compute it&lt;br /&gt;
 a + b - c + 20   =&amp;gt; can be computed if a, b and c are known&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Variables = &lt;br /&gt;
&lt;br /&gt;
A memory variable can contain a value (integer number, floating number, text character etc.). It is useful to use variables instead of repeating hard wired numbers. Here the same example, this time using a variable for the LED pin:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 // declare an integer variable named 'pinLED' and assign it the value 13&lt;br /&gt;
 int pinLED = 13;       // this is a comment&lt;br /&gt;
&lt;br /&gt;
 void setup() {&lt;br /&gt;
   pinMode(pinLED, OUTPUT);   // here, we use the variable named 'pinLED' instead of the hard-wired number&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 void loop() {&lt;br /&gt;
   digitalWrite(pinLED, HIGH);    // here, we use again the variable 'pinLED'&lt;br /&gt;
   delay(1000);              &lt;br /&gt;
   digitalWrite(pinLED, LOW);     // here, we use again the variable 'pinLED'&lt;br /&gt;
   delay(1000);              &lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Try it out! Variables can be integer number, floating numbers, logical (TRUE/FALSE), and text characters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 int someIntegerNumber = 42;&lt;br /&gt;
 boolean someLogical = TRUE;&lt;br /&gt;
 float someFloatingNumber = 3.1419;&lt;br /&gt;
 char someCharacters[] = &amp;quot;Hello World&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A variable's contents can be re-assigned at any time in the program:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 int pinLED = 13;   // declare variable named pinLED and initialize it with value 13&lt;br /&gt;
 pinLED = 12;       // assign pinLED a new value (12)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can even use calculations/expressions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 int A = 4;&lt;br /&gt;
 int B = A * 42 + 15;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You may wonder what the values 'HIGH' and 'LOW' in the above code example are. These are integer constants that the Arduino library already did define for you (HIGH = 1, LOW = 0). Using variables and constants makes code more human-readable.&lt;br /&gt;
&lt;br /&gt;
= Functions =&lt;br /&gt;
&lt;br /&gt;
We did use three pre-defined functions already in above code which are already defined by the Arduino library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 pinMode&lt;br /&gt;
 digitalWrite&lt;br /&gt;
 delay&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally, we already defined ourselves two functions in above code: 'setup' and 'loop'. Functions group commands into blocks. These blocks are then called by the name of the function. A function can also have input parameters, and one output parameter.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 // Declares a function named 'writeAndWait' to set LED to a given value (HIGH/LOW) and wait &lt;br /&gt;
 void writeAndWait(int value){&lt;br /&gt;
   digitalWrite(pinLED, value);    // here, we use the parameter 'value' instead of a fixed HIGH/LOW value&lt;br /&gt;
   delay(1000);                &lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can use that new function to make the main loop more readable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 void loop() {&lt;br /&gt;
   writeAndWait(HIGH);  // call function with 'HIGH' (for parameter 'value') &lt;br /&gt;
   writeAndWait(LOW);   // call function with 'LOW' (for parameter 'value')&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After each statement (variable assignment, function call etc.) we make a semicolon. The semicolon divides the current statement and the next statement. Try it out!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Optionally, a function can return a value. In this example, the function named 'addSomething' will compute the sum of its input parameters 'a' and 'b' and return that computed sum.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 int addSomething(int a, int b){&lt;br /&gt;
   return a + b;&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you use your new function to compute the sum of any integer values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 int c = addSomething( 4, 5 );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Serial console output and text =&lt;br /&gt;
To get feedback from your Arduino, you may want to use the serial console. Let's see a simple example. Run this program and open your Arduino IDE serial console (CTRL+SHIFT+M) at 19200 baud and look if it returns the text.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 void setup(){&lt;br /&gt;
   Serial.begin(19200);  // set the baud rate to use&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 void loop(){&lt;br /&gt;
   Serial.println(&amp;quot;Hello world&amp;quot;); // output the text to Arduino serial console&lt;br /&gt;
   delay(1000);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= For-loops and blocks =&lt;br /&gt;
To repeat things, use for-loops. This example will repeat outputting the text by using a variable ('counter') that counts from 0 to 3. Each time the loop is executed, the variable 'counter' will increase by one:&lt;br /&gt;
&lt;br /&gt;
 Hello 0&lt;br /&gt;
 Hello 1&lt;br /&gt;
 Hello 2&lt;br /&gt;
 Hello 3&lt;br /&gt;
 ... then the main loop restarts...&lt;br /&gt;
&lt;br /&gt;
The example uses a block indicated by '{ ... }'. Everything that is inside this block is run each time the for-loop increases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 void loop(){  &lt;br /&gt;
   for (int counter=0; counter &amp;lt; 4; counter++)&lt;br /&gt;
   {&lt;br /&gt;
     Serial.print(&amp;quot;Hello &amp;quot;);&lt;br /&gt;
     Serial.println(counter);&lt;br /&gt;
   }&lt;br /&gt;
   delay(1000);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Try it out!&lt;br /&gt;
&lt;br /&gt;
= Digital input =&lt;br /&gt;
Let's read the ouside world - we'll read the state of digital pin 5 in this example. We use the Arduino internal pull-up resistor (so pin 5 is HIGH when the switch is open). Simply connect pin 5 to GND to make the switch going LOW.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 int pinSwitch = 5; // connect this pin to GND to activate the switch&lt;br /&gt;
 int pinLED = 13;  // we use the Arduino onboard LED&lt;br /&gt;
&lt;br /&gt;
 void setup(){&lt;br /&gt;
   // configure the switch pin to use the Arduino internal pull-up resistor&lt;br /&gt;
   pinMode(pinSwitch, INPUT_PULLUP);&lt;br /&gt;
   pinMode(pinLED, OUTPUT);&lt;br /&gt;
   Serial.begin(19200);  &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 void loop(){  &lt;br /&gt;
   // read the value of the switch pin - it is '1' when HIGH, and '0' when LOW.&lt;br /&gt;
   int value = digitalRead( pinSwitch );&lt;br /&gt;
   Serial.print(&amp;quot;The switch is &amp;quot;); &lt;br /&gt;
   Serial.println( value ); &lt;br /&gt;
   // write the value to the LED pin - it will be HIGH when writing a '1', and LOW when writing a '0'.&lt;br /&gt;
   digitalWrite( pinLED, value );&lt;br /&gt;
   delay(1000);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Try it out!&lt;br /&gt;
&lt;br /&gt;
= If-clauses =&lt;br /&gt;
For running code based on conditions, use if-clauses. If the condition for the if-clause evaluates to logical-TRUE, the first block is called, otherwise the else block.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 void loop(){&lt;br /&gt;
   int value = digitalRead ( pinSwitch );&lt;br /&gt;
   if (value == HIGH){&lt;br /&gt;
     Serial.println( &amp;quot;The switch is HIGH&amp;quot; );&lt;br /&gt;
   } &lt;br /&gt;
   else  {&lt;br /&gt;
     Serial.println( &amp;quot;The switch is LOW&amp;quot; );    &lt;br /&gt;
   }&lt;br /&gt;
   delay(1000);&lt;br /&gt;
 }  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conditions can be more complex of course:&lt;br /&gt;
&lt;br /&gt;
 if (numberX &amp;gt; 5)... // variable 'numberX' must be larger than 5&lt;br /&gt;
 if (numberX &amp;gt; numberY) ... // variable 'numberX' must be larger than variable 'numberY'&lt;br /&gt;
 if (numberX == numberY) ... // 'numberX ' must be equal 'numberY'&lt;br /&gt;
 if (numberX &amp;lt; numberY) ... // 'numberX' must be smaller than 'numberY'&lt;br /&gt;
&lt;br /&gt;
Also you can combine multiple conditions:&lt;br /&gt;
&lt;br /&gt;
 if ( (number &amp;gt; 5) &amp;amp;&amp;amp; (number &amp;lt; 10) )... // logical AND: both conditions must be TRUE&lt;br /&gt;
 if ( (number &amp;lt; 5) || (number &amp;gt; 10) )... // logical OR: only one condition must be TRUE&lt;br /&gt;
&lt;br /&gt;
= What you have learned =&lt;br /&gt;
*Variables can contain numbers (integer, float) or text (characters) and are placeholders for them.&lt;br /&gt;
*Functions can containe blocks of code and are placeholders for the blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Further links =&lt;/div&gt;</summary>
		<author><name>Unlogic</name></author>	</entry>

	</feed>