Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
odroid_go:arduino:02_hello_world [2018/06/11 17:04]
joshua ↷ Page name changed from internal:odroid_go:arduino:hello_world to internal:odroid_go:arduino:02_hello_world
odroid_go:arduino:02_hello_world [2018/06/18 18:27]
luke.go ↷ Page moved from internal:odroid_go:arduino:02_hello_world to odroid_go:arduino:02_hello_world
Line 2: Line 2:
 {{:​accessory:​odroid_go:​hello.jpg?​300|}} {{:​accessory:​odroid_go:​hello.jpg?​300|}}
 <WRAP important round> <WRAP important round>
-  * Make sure that you've followed **[[01_arduino_setup|Arduino setup]]** guide.+  * Make sure that you've followed ​the **[[01_arduino_setup|Arduino setup]]** guide.
 </​WRAP>​ </​WRAP>​
-You will write code to display "​**Hello,​ ODROID-GO**"​ on your ODROID-GO by following this guide.\\ ​+You will write code to display "​**Hello,​ ODROID-GO**"​ on your ODROID-GO by following this guide.\\ ​
  
 ===== Basic code structure for Arduino ===== ===== Basic code structure for Arduino =====
-When you run Arduino IDE at first then you can see the screen like below.\\ ​+When you first run the Arduino IDEyou will see screen like below.\\ ​
 {{:​internal:​odroid_go:​arduino:​go_arduino_helloworld1.png?​400|}}\\ ​ {{:​internal:​odroid_go:​arduino:​go_arduino_helloworld1.png?​400|}}\\ ​
 That editor is called **sketch**, and this is your playground.\\ ​ That editor is called **sketch**, and this is your playground.\\ ​
  
-The default source code is,\\ +The default source code is:\\ 
 <code c> <code c>
 void setup() { void setup() {
Line 23: Line 23:
 } }
 </​code>​ </​code>​
-There are 2 functions with some comments that lets you know how it performed ​in the code.\\ ​+There are 2 functions with some comments that let you know what it performs ​in the code.\\ ​
 We will use this simple structure.\\ ​ We will use this simple structure.\\ ​
 ===== Arduino for ODROID-GO ===== ===== Arduino for ODROID-GO =====
 We're providing a library for Arduino development:​ **odroid_go.h**.\\ ​ We're providing a library for Arduino development:​ **odroid_go.h**.\\ ​
-That library helps you **to control the components** on the board such as LCD, a lot of buttons, speaker, etc.\\  +The library helps you **to control the components** on the board such as LCD, a lot of buttons, speaker, etc.\\  
-So you should ​include that library ​first.\\ ​+This library ​should ​be included ​first.\\ ​
  
-The board isn't ready so that should be initialized. **To initialize the board**, use **GO.begin()** function.\\  +To prepare the board for use, it should be initialized. **To initialize the board**, use the **GO.begin()** function.\\  
-And If you want to control the buttons or the speaker on the board, you have to use **GO.update()** function to apply the changes ​on them by the code.\\  +If you want to control the buttons or the speaker on the board, you have to use the **GO.update()** function to apply the changes ​from the code.\\  
-But that **GO.update()** function isn't used in this guide using only LCD to display a simple string.\\ ​+The **GO.update()** function isn't used in this guide since only the LCD will be used to display a simple string.\\ ​
  
-Okay let's see the code which is reflecting them.\\ +Okaylet's see the code.\\ ​
 <code c> <code c>
 #include <​odroid_go.h>​ #include <​odroid_go.h>​
Line 48: Line 48:
 } }
 </​code>​ </​code>​
-GO.begin() function has to be in **setup()** function ​to be started ​only once.\\ ​+The **GO.begin()** function has to be in the **setup()** function ​since its called ​only once.\\ ​
  
-And the **GO** instance has not only that 2 core functions but also a lot of helper functions that lets you to control the components on the board.\\  +The **GO** instance has not only the 2 core functions but also a lot of helper functions that let you control the components on the board.\\  
-Now let's use **GO.lcd** functions to show "​**Hello,​ ODROID-GO**"​.\\ ​+Nowlet's use the **GO.lcd** functions to show "​**Hello,​ ODROID-GO**"​.\\ ​
 ===== Hello World ===== ===== Hello World =====
-We will use **GO.lcd.print** function to show the string.\\ ​+We will use the **GO.lcd.print** function to show string.\\ ​
 <code c> <code c>
 #include <​odroid_go.h>​ #include <​odroid_go.h>​
Line 69: Line 69:
 } }
 </​code>​ </​code>​
-The sketch looks fine but the texts on the LCD will be too small to see.\\  +The sketch looks finebut the text on the LCD will be too small to see.\\  
-Let's increase the font size to 2 by using **GO.lcd.setTextSize()** function.\\ ​+Let's increase the font size to 2 by using the **GO.lcd.setTextSize()** function.\\ ​
 <code c> <code c>
 #include <​odroid_go.h>​ #include <​odroid_go.h>​
Line 85: Line 85:
   // put your main code here, to run repeatedly:   // put your main code here, to run repeatedly:
    
 +}
 +</​code>​
 +
 +You can also change the text color with **GO.lcd.setTextColor()**. Change the text to green.\\ ​
 +<code c>
 +#include <​odroid_go.h>​
 +
 +void setup() {
 +  // put your setup code here, to run once:
 +  GO.begin();
 +  ​
 +  GO.lcd.setTextSize(2);​
 +  GO.lcd.setTextColor(GREEN);​
 +  GO.lcd.print("​Hello,​ ODROID-GO"​);​
 +}
 + 
 +void loop() {
 +  // put your main code here, to run repeatedly:
 + 
 +}
 +</​code>​
 +
 +Additionally,​ as an advanced feature, we've added a function called **displayGO()** which includes using several effects.\\ ​
 +New functions introduced:​\\ ​
 +  * **GO.lcd.setRotation()**:​ rotates output screen. The rotation parameter can be 0 to 7.
 +  * **GO.lcd.clearDisplay()**:​ resets all texts on the screen.
 +  * **GO.lcd.setTextFont()**:​ sets font style after calling this. A given font names in number.
 +<code c>
 +#include <​odroid_go.h>​
 +
 +uint8_t idx;
 +uint8_t rotate;
 +
 +void setup() {
 +  // put your setup code here, to run once:
 +  GO.begin();
 +
 +  GO.lcd.println("​Hello,​ ODROID-GO"​);​
 +  delay(1000);​
 +}
 +
 +void displayGO() {
 +  GO.lcd.clearDisplay();​
 +  GO.lcd.setRotation(rotate + 4);
 +  GO.lcd.setCursor(30,​ 40);
 +  ​
 +  if (idx) {
 +    GO.lcd.setTextSize(1);​
 +    GO.lcd.setTextFont(4);​
 +    GO.lcd.setTextColor(MAGENTA);​
 +  } else {
 +    GO.lcd.setTextSize(2);​
 +    GO.lcd.setTextFont(1);​
 +    GO.lcd.setTextColor(GREEN);​
 +  }
 +  GO.lcd.print("​Hello,​ ODROID-GO"​);​
 +  ​
 +  idx = !idx;
 +  rotate++;
 +  rotate %= 4;
 +  ​
 +  delay(1000);​
 +}
 +
 +void loop() {
 +  // put your main code here, to run repeatedly:
 +  displayGO();​
 } }
 </​code>​ </​code>​
  
 You can verify/​compile or upload a sketch from the **toolbar** or **Sketch** menu.\\ ​ You can verify/​compile or upload a sketch from the **toolbar** or **Sketch** menu.\\ ​
-Also you can use the helpful **shortcuts**.\\ ​+Alsoyou can use helpful **shortcuts**.\\ ​
   * **CTRL-R**: Verify and compile.   * **CTRL-R**: Verify and compile.
   * **CTRL-U**: Upload.   * **CTRL-U**: Upload.
  
-Before ​upload ​the binary, you have to select **proper port** at the **Tools - Port** menu.\\ ​+Before ​uploading ​the binary, you have to select ​the **proper port** at the **Tools - Port** menu.\\  
 + 
 +If the procedure goes well, you can see **"​Hello,​ ODROID-GO"​** on your device.\\  
 +{{:​accessory:​odroid_go:​hello.jpg?​200|}}\\  
 + 
 +===== A completed example ===== 
 +The complete example is available as follows:\\ 
  
-If all the procedure does well, you can see **"​Hello, ​ODROID-GO"** on your device.\\  +Click the **Files -> Examples -> ODROID-GO ​-> Hello_World** menu to import and press **CTRL-U** to compile/​upload.\\  
-{{:accessory:odroid_go:hello.jpg?200|}}+{{:internal:odroid_go:arduino:​windows_ws_3.png?400|}}\\