GR-ADZUKI GPIO OUTPUT SAMPLE

Pocket

まずは、基本的なI/Oの使用方法を説明します。
GR-ADZUKIには、6個のLEDが基板上にあります。LEDは、単色でなくRGBカラーのLEDです。色の選択は、全LEDで共通ラインになっているので全てのLEDは、同時に同じ色になります。
プログラムを見ていきます。
まず最初に LEDの名前とピンの番号を設定します。

LEDのピン番号は、6、9、10、11、12、13です。
int led1 = 6;
int led2 = 9;
int led3 = 10;
int led4 = 11;
int led5 = 12;
int led6 = 13;

色の線は、赤が22、緑が23、青が24です。
int led_R = 22;
int led_G = 23;
int led_B = 24;

ピン番号は、添付のカードに書いてあります。
表には、基板上のピンの配置、裏は、機能ごとにまとめられています。
次にsetup()関数でピンのモードを決めます。
全て出力のOUTPUT指定とします。
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led_R, OUTPUT);
pinMode(led_G, OUTPUT);
pinMode(led_B, OUTPUT);

ここで今回は、青色を光らせたいので青だけHIGHにします。
digitalWrite(led_R, LOW); // RED LED COMMON
digitalWrite(led_G, LOW); // GREEN LED COMMON
digitalWrite(led_B, HIGH); // BLUE LED COMMON
光らせたい色をHIGHにします。
2色光らせれば、混合色になります。
全部光らせれば白色になります。

次にloop()関数で1秒ごとにLEDを点滅します。
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led6, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led6, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second

digitalWrite()関数で出力のON/OFFを切り替えます。
1個目の引数がピン名、2個目の引数が出力設定です。点けたいLEDのみをHIGHにします。LED1、3、5とLED2、4、6を1秒ごとに交互に点滅させます。

サンプルは以下にあります。
https://github.com/jendo1969/GR-ADZUKI/blob/master/Blink.ino

First, I will explain how to use basic I/O.
GR-ADZUKI has 6LEDs on the board. LED is RGB color LED, not monochrome. Since the color selection is a common line for all LEDs, all the LEDs will have the same color at the same time.
I will look at the program.
First set the LED name and pin number.
The LED pin numbers are 6, 9, 10, 11, 12, 13.
int led1 = 6;
int led2 = 9;
int led3 = 10;
int led4 = 11;
int led5 = 12;
int led6 = 13;

Color lines are 22 for red, 23 for green and 24 for blue.
int led_R = 22;
int led_G = 23;
int led_B = 24;

The pin number is written on the attached card.
In the table, the arrangement of the pins on the board and the back are summarized for each function.
Next, use the setup() function to determine the mode of the pin.
All output is specified as OUTPUT.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led_R, OUTPUT);
pinMode(led_G, OUTPUT);
pinMode(led_B, OUTPUT);

Here, I want only blue to be HIGH because I want to make the blue light shine this time.
digitalWrite(led_R, LOW); // RED LED COMMON
digitalWrite(led_G, LOW); // GREEN LED COMMON
digitalWrite(led_B, HIGH); // BLUE LED COMMON
Set the color you want to light to HIGH.
If you shine two colors, it will be a mixed color.
It turns white if it glows all.

Next, the LED flashes every second with the loop() function.
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led6, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led6, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second

Use the digitalWrite() function to switch the output ON/OFF.
The first argument is the pin name and the second argument is the output setting. Set only the LED you want to turn on HIGH. LED 1, 3, 5 and LED 2, 4, 6 alternately blink every second.
Samples are below.
https://github.com/jendo1969/GR-ADZUKI/blob/master/Blink.ino


首先,我將解釋如何使用基本的I/O。

GR-ADZUKI在電路板上有6個LED。 LED是RGB彩色LED,不是單色的。 由於顏色選擇是所有LED的通用線,所有的LED將同時具有相同的顏色。
我會看看這個節目。
首先設置LED名稱和PIN碼。

LED引腳編號是6,9,10,11,12,13。
int led1 = 6;
int led2 = 9;
int led3 = 10;
int led4 = 11;
int led5 = 12;
int led6 = 13;

顏色線是紅色的22,綠色的23,藍色的24。
int led_R = 22;
int led_G = 23;
int led_B = 24;

PIN碼寫在所連接的卡上。
在表格中,每個功能總結了電路板和背面的引腳排列。
接下來,使用setup()函數確定引腳的模式。
所有輸出都被指定為OUTPUT。
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led_R, OUTPUT);
pinMode(led_G, OUTPUT);
pinMode(led_B, OUTPUT);

在這裡,我想這次使藍色變高,因為我想點亮藍色。
digitalWrite(led_R, LOW); // RED LED COMMON
digitalWrite(led_G, LOW); // GREEN LED COMMON
digitalWrite(led_B, HIGH); // BLUE LED COMMON
將想要點亮的顏色設置為HIGH。
如果你發出兩種顏色,它將是一種混合的顏色。
它變成白色,如果它發光所有。

接下來,使用loop()函數,LED每秒閃爍一次。
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led6, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led6, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second

使用digitalWrite()函數來切換輸出ON/OFF。
第一個參數是引腳名稱,第二個參數是輸出設置。 只設置你想打開HIGH的LED。 LED 1,3,5和LED 2,4,6每秒鐘交替閃爍。
樣本如下。
https://github.com/jendo1969/GR-ADZUKI/blob/master/Blink.ino

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください