{"id":13,"date":"2024-04-04T03:16:32","date_gmt":"2024-04-04T00:16:32","guid":{"rendered":"https:\/\/sisu.ut.ee\/robot\/32-programmeerimise-pohitoed\/"},"modified":"2024-04-04T03:16:44","modified_gmt":"2024-04-04T00:16:44","slug":"32-programmeerimise-pohitoed","status":"publish","type":"page","link":"https:\/\/sisu.ut.ee\/robot\/32-programmeerimise-pohitoed\/","title":{"rendered":"3.2. Programmeerimise p\u00f5hit\u00f5ed"},"content":{"rendered":"<p><span data-mce-mark=\"1\">N\u00fc\u00fcd oled Arduino keskkonnaga tuttav. J\u00e4rgmisena \u00f5pid kuidas robotit programmeerida keeles C++. K\u00f5igepealt tutvud kelle p\u00f5hit\u00f5dedega, n\u00e4iteks muutujate t\u00fc\u00fcbid ja operandid. J\u00e4rgnevalt \u00f5pid kasutama tingimuslauseid, ts\u00fckleid ning funktsioone.<\/span><\/p>\n<p>Nendes loengutes on palju infot ning oluline pole mitte kohe k\u00f5igest aru saada ning kasutada osata vaid, et tulevaste \u00fclesannete teaksid, kus vajaminev info on.<\/p>\n<p>Esimene video r\u00e4\u00e4gib koodi \u00fclesehitusest, muutujate t\u00fc\u00fcpides ning operandidest.<\/p>\n<p><span data-mce-mark=\"1\"><div class=\"ratio ratio-16x9 mb-3\"><div class=\"video-placeholder-wrapper video-placeholder-wrapper--16x9\">\n\t\t\t    <div class=\"video-placeholder d-flex justify-content-center align-items-center\">\n\t\t\t        <div class=\"overlay text-white p-2 w-100 text-center d-block justify-content-center align-items-center\">\n\t\t\t            <div>Kolmandate osapoolte sisu n\u00e4gemiseks palun n\u00f5ustu k\u00fcpsistega.<\/div>\n\t\t\t            <button class=\"btn btn-secondary btn-sm mt-1 consent-change\">Muuda n\u00f5usolekut<\/button>\n\t\t\t        <\/div>\n\t\t\t    <\/div>\n\t\t\t<\/div>\n<\/div><\/span><\/p>\n\n<p style=\"text-align: center\"><a href=\"https:\/\/youtu.be\/G3Hsd1OFWfU\" target=\"_blank\" rel=\"noopener\">https:\/\/youtu.be\/G3Hsd1OFWfU<\/a><\/p>\n\n<p>Teise video sisuks on tingimuslaused, ts\u00fcklid ning funktsioonid.<\/p>\n<p><span data-mce-mark=\"1\"><div class=\"ratio ratio-16x9 mb-3\"><div class=\"video-placeholder-wrapper video-placeholder-wrapper--16x9\">\n\t\t\t    <div class=\"video-placeholder d-flex justify-content-center align-items-center\">\n\t\t\t        <div class=\"overlay text-white p-2 w-100 text-center d-block justify-content-center align-items-center\">\n\t\t\t            <div>Kolmandate osapoolte sisu n\u00e4gemiseks palun n\u00f5ustu k\u00fcpsistega.<\/div>\n\t\t\t            <button class=\"btn btn-secondary btn-sm mt-1 consent-change\">Muuda n\u00f5usolekut<\/button>\n\t\t\t        <\/div>\n\t\t\t    <\/div>\n\t\t\t<\/div>\n<\/div><\/span><\/p>\n\n<p style=\"text-align: center\"><a href=\"https:\/\/youtu.be\/j3NzXJ9CUis\" target=\"_blank\" rel=\"noopener\">https:\/\/youtu.be\/j3NzXJ9CUis<\/a><\/p>\n<p><span data-mce-mark=\"1\"><\/span><\/p>\n<p>Lisainfot leiad aadressilt\u00a0<a style=\"background-color: #ffffff\" href=\"http:\/\/www.tutorialspoint.com\/arduino\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.tutorialspoint.com\/arduino\/<\/a><\/p>\n<p><span data-mce-mark=\"1\"><\/span><\/p>\n<p><span data-mce-mark=\"1\"><span data-mce-mark=\"1\">Videotes k\u00e4sitletud olulise info leiad ka allj\u00e4rgnevatest tabelitest.<\/span><\/span><\/p>\n<h2>ASCII s\u00fcmbolite tabel<\/h2>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" width=\"791\" height=\"479\" class=\"alignnone wp-image-29\" src=\"https:\/\/sisu.ut.ee\/wp-content\/uploads\/sites\/198\/800px-ascii-table-wide.svg_.png\" title=\"800px-ascii-table-wide.svg_.png\" alt=\"800px-ascii-table-wide.svg_.png\" srcset=\"https:\/\/sisu.ut.ee\/wp-content\/uploads\/sites\/198\/800px-ascii-table-wide.svg_.png 791w, https:\/\/sisu.ut.ee\/wp-content\/uploads\/sites\/198\/800px-ascii-table-wide.svg_-300x182.png 300w, https:\/\/sisu.ut.ee\/wp-content\/uploads\/sites\/198\/800px-ascii-table-wide.svg_-768x465.png 768w\" sizes=\"auto, (max-width: 791px) 100vw, 791px\"><br><a style=\"text-align: center;background-color: #ffffff\" href=\"https:\/\/commons.wikimedia.org\/wiki\/File:ASCII-Table-wide.svg\" target=\"_blank\" rel=\"noopener\"><span>https:\/\/commons.wikimedia.org\/wiki\/File:ASCII-Table-wide.svg<\/span><\/a><\/p>\n\n<h2>Muutujate t\u00fc\u00fcbid<\/h2>\n<ul>\n<li>\n<p><span data-mce-mark=\"1\">void<\/span><\/p>\n<\/li>\n<ul>\n<li>Kasutatakse funktsioonide loomisel<\/li>\n<li>void loop() {}<\/li>\n<\/ul>\n<li>\n<p><span data-mce-mark=\"1\">bool<\/span><\/p>\n<\/li>\n<ul>\n<li>T\u00f5ev\u00e4\u00e4rtus (true\/false)<\/li>\n<li>bool valmis = false;<\/li>\n<\/ul>\n<li>\n<p><span data-mce-mark=\"1\">char<\/span><\/p>\n<\/li>\n<ul>\n<li>\u00dcks ASCII s\u00fcmbol<\/li>\n<li>char symbol = \u2018r\u2019;<\/li>\n<\/ul>\n<li>\n<p><span data-mce-mark=\"1\">short<\/span><\/p>\n<\/li>\n<ul>\n<li>T\u00e4isarv vahemikus -32 768..32 767<\/li>\n<li>short number = 1456;<\/li>\n<\/ul>\n<li>\n<p><span data-mce-mark=\"1\">(unsigned) int<\/span><\/p>\n<\/li>\n<ul>\n<li>T\u00e4isarv vahemikus (0..65 535) -32 768..32 767<\/li>\n<li>int teineNumber = -10;<\/li>\n<\/ul>\n<li>\n<p><span data-mce-mark=\"1\">float<\/span><\/p>\n<\/li>\n<ul>\n<li>Ujukomaarv vahemikus -3.4\u00b710<sup>38<\/sup>..3.4\u00b710<sup>38<\/sup><\/li>\n<li>float pi = 3.14;<\/li>\n<\/ul>\n<li>\n<p><span data-mce-mark=\"1\">double<\/span><\/p>\n<\/li>\n<ul>\n<li>Ujukomaarv vahemikus -3.4\u00b710<sup>38<\/sup>..3.4\u00b710<sup>38<\/sup><\/li>\n<li>double negPi = -3.14;<\/li>\n<\/ul>\n<\/ul>\n<h2>Operandid<\/h2>\n<p><strong>A = 10 ja B = 20<\/strong><\/p>\n<div>\n<table class=\"table table-hover\" style=\"border-color: #eee;border-width: 1px;border-style: solid\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"text-align: center\">\n<p><strong>Operandi nimi<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center\">\n<p><strong>Operand<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center;width: 40%\">\n<p><strong>Kirjeldus<\/strong><\/p>\n<\/td>\n<td style=\"text-align: center\">\n<p><strong>N\u00e4ide<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Omistamine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">=<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Annab v\u00f5rdusm\u00e4rgist vasakul olevale muutujale sama v\u00e4\u00e4rtuse, mis on v\u00f5rdusm\u00e4rgist paremal<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A = B \u2192 A = 20, B = 20<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Liitmine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">+<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Liidab kaks muutujat<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A+B \u2192 30<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Lahutamine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">\u2013<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Lahutab teise muutuja esimesest<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A-B \u2192 -10<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Korrutamine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">*<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Korrutab muutujate v\u00e4\u00e4rtused<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A*B \u2192 200<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Jagamine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">\/<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Jagab muutujad<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">B\/A \u2192 2<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">J\u00e4\u00e4giga jagamine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">%<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">J\u00e4\u00e4giga jagamine, tulemuseks on j\u00e4\u00e4k<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">B%A \u2192 0<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">V\u00f5rdne<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">==<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Kui v\u00e4\u00e4rtused on v\u00f5rdsed, siis tagastab true<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A == B \u2192 false<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Ei ole v\u00f5rdne<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">!=<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Kui v\u00e4\u00e4rtused ei ole v\u00f5rdsed, siis tagastab true<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A != B \u2192 true<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">V\u00e4iksem kui<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">&lt;<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Kui esimene v\u00e4\u00e4rtus on v\u00e4iksem kui teine, siis tagastab true<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A &lt; B \u2192 true<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Rohkem kui<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">&gt;<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Kui esimene v\u00e4\u00e4rtus on suurem kui teine, siis tagastab true<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A &gt; B \u2192 false<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">V\u00e4iksem v\u00f5i v\u00f5rdne kui<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">&lt;=<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Kui esimene v\u00e4\u00e4rtus on v\u00e4iksem v\u00f5i v\u00f5rdne kui teine, siis tagastab true<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A &lt;= B \u2192 true<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Suurem v\u00f5i v\u00f5rdne kui<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">&gt;=<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Kui esimene v\u00e4\u00e4rtus on suurem v\u00f5i v\u00f5rdne kui teine, siis tagastab true<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A &gt;= B \u2192 false<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Ja<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">&amp;&amp;<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Kui vasak ja parem pool on true, siis tagastab true<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">(A == 10) &amp;&amp; (B == 20) \u2192 true<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">V\u00f5i<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">||<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Kui vasak v\u00f5i parem pool on true, siis tagastab true<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">(A == 10)\u00a0<span data-mce-mark=\"1\">||<\/span> (B == 10) \u2192 true<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Ei<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">!<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Kui muutuja on false tagastab true ning vastupidi<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">!(A == 10) \u2192 false<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Suurenda<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">++<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Suurendab t\u00e4isarv muutujat \u00fche v\u00f5rra<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A++ \u2192 A=11<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">V\u00e4henda<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">\u2014<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">V\u00e4hendab t\u00e4isarv muutujat \u00fche v\u00e4rra<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A\u2013 \u2192 A=9<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Liit-liitmine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">+=<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Vasaku muutuja v\u00e4\u00e4rtuseks saab m\u00f5lema muutuja summa<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A += B \u2192 A=30, B=20<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Liit-lahutamine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">-=<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Vasaku muutuja v\u00e4\u00e4rtuseks saab parem muutuja lahutatud vasakust<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A -= B \u2192 A=-10, B=20<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Liit-korrutamine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">*=<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Vasaku muutuja v\u00e4\u00e4rtuseks m\u00f5lema muutuja korrutis<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">A *= B \u2192 A=200, B=20<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Liit-jagamine<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">\/=<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Vasaku muutuja v\u00e4\u00e4rtuseks saab vasak muutuja jagatud paremaga<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">B \/= A \u2192 A=10, B=2<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p><span data-mce-mark=\"1\">Liit-j\u00e4\u00e4k<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">%=<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">Vasaku muutuja v\u00e4\u00e4rtuseks saab j\u00e4\u00e4giga jagamise tulemus parema ja vasaku vahel<\/span><\/p>\n<\/td>\n<td>\n<p><span data-mce-mark=\"1\">B %= A \u2192 A=10, B=0<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>N\u00fc\u00fcd oled Arduino keskkonnaga tuttav. J\u00e4rgmisena \u00f5pid kuidas robotit programmeerida keeles C++. K\u00f5igepealt tutvud kelle p\u00f5hit\u00f5dedega, n\u00e4iteks muutujate t\u00fc\u00fcbid ja operandid. J\u00e4rgnevalt \u00f5pid kasutama tingimuslauseid, ts\u00fckleid ning funktsioone. Nendes loengutes on palju infot ning oluline pole mitte kohe k\u00f5igest aru &#8230;<\/p>\n","protected":false},"author":98,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"class_list":["post-13","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/sisu.ut.ee\/robot\/wp-json\/wp\/v2\/pages\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sisu.ut.ee\/robot\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sisu.ut.ee\/robot\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sisu.ut.ee\/robot\/wp-json\/wp\/v2\/users\/98"}],"replies":[{"embeddable":true,"href":"https:\/\/sisu.ut.ee\/robot\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":1,"href":"https:\/\/sisu.ut.ee\/robot\/wp-json\/wp\/v2\/pages\/13\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/sisu.ut.ee\/robot\/wp-json\/wp\/v2\/pages\/13\/revisions\/105"}],"wp:attachment":[{"href":"https:\/\/sisu.ut.ee\/robot\/wp-json\/wp\/v2\/media?parent=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}