# TRT 11 Archive Pemateri: Mohammad Aryasatya Arifien ## Materials & Links ### Link: * [Referensi Programming Arduino](https://arduino.cc/reference/en) * [Server Discord Komunitas Arduino](https://discord.gg/arduino-420594746990526466) ### Materi: * [Larut I -- Pengenalan Arduino](https://drive.google.com/file/d/1RH7yZekfSWNsDhmeIzEYwe_L3xAhaPJG/view?usp=sharing) ## Programming ### 1. Istilah #### 1.1 Operator dan operand ```cpp= int contoh = 69 * 420 + 654321; ``` Di sini, `69`, `420`, dan `654321` berperan sebagai *operand*, sedangkan `*` dan `+` berperan sebagai *operator*. #### 1.2 Identifier Identifier adalah "nama" yang diberikan pada *variable* atau *function* ### 2. Expression Sebuah *expression* adalah suatu deretan operator dan operand yang digunakan untuk: - Menghitung nilai dari operand - Menimbulkan "side effect" #### 2.1 Operators ### 3. Statement ### 4. Variabel #### 4.1 Deklarasi variabel ```cpp= // bentuk tipe_data identifier1; tipe_data identifier2 = nilai; // contoh int funni = 69420; char name[] = "Firebloom"; // [] penanda array // identifier1 dan identifier2 // tidak boleh berupa keyword ``` #### 4.2 Tipe data | Tipe Data | Keterangan | Range nilai | Size | | -------- | -------- | ------ | --- | | <span style="color:blue;">`bool`|True or False | $0$ atau $1$ | 1 byte| |<span style="color:blue;">`char`| Karakter (huruf) | $-128$ hingga $127$ | 1 byte | |<span style="color:blue;">`unsigned char`</span> | Karakter (huruf) | $0$ hingga $255$ | 1 byte | <span style="color:blue;">`int` | Bilangan bulat | $-2^{31}$ hingga $2^{31} - 1$ | 4 bytes | | <span style="color:blue;">`unsigned int`| Bilangan bulat | $0$ hingga $2^{32} - 1$ | 4 bytes | | <span style="color:blue;">`long` | Bilangan bulat | $-2^{63}$ hingga $2^{63} - 1$ | 8 bytes | | <span style="color:blue;">`unsigned long`| Bilangan bulat | $0$ hingga $2^{64} - 1$ | 8 bytes | |<span style="color:blue;">`float`|Bilangan desimal||4 bytes| |<span style="color:blue;">`unsigned float`|Bilangan desimal||4 bytes| |<span style="color:blue;">`double`|Bilangan desimal||8 bytes| |<span style="color:blue;">`unsigned double`|Bilangan desimal||8 bytes| ### 5. Control Flow #### 5.1 `if` statement ```cpp= // bentuk 1 if (condition) statement; // bentuk 2 if (condition) statement; // bentuk 3 if (condition) { statement1; statement2; statement3; } int ganjil = 69; int genap = 420; if (genap > ganjil) ``` #### 5.2 `while` statement #### 5.3 `for` statement ## Larut ### Larut 1 -- Kamis, 11 Januari 2024 * Pengenalan Arduino, [Arduino IDE](https://www.arduino.cc/en/software), dan [Tinkercad](https://tinkercad.com) * [Materi Pengenalan Arduino](https://drive.google.com/file/d/1RH7yZekfSWNsDhmeIzEYwe_L3xAhaPJG/view?usp=sharing) ### Larut 2 -- Kamis, 18 Januari 2024 * Pengenalan *control flow* (`if`, `else if`, dan `else` block). * Rangkaian ![](https://hackmd.io/_uploads/S1fTf_IF6.png) * Kodingan ```cpp= int const LED = 12; int const LED2 = 11; int const LED3 = 10; int count = 0; void setup() { pinMode(LED, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); } void loop() { if (count % 3 == 0) { digitalWrite(LED, HIGH); delay(1000); digitalWrite(LED, LOW); delay(1000); // Wait for 1000 millisecond(s) } else if (count % 3 == 1) { digitalWrite(LED2, HIGH); delay(1000); // Wait for 1000 millisecond(s) digitalWrite(LED2, LOW); delay(1000); } else { digitalWrite(LED3, HIGH); delay(1000); // Wait for 1000 millisecond(s) digitalWrite(LED3, LOW); delay(1000); } count++; } ``` ### Larut 3 -- TBD