LoginSignup
1
0

More than 5 years have passed since last update.

arduinoでシリアル

Last updated at Posted at 2018-02-25

概要

arduinoでシリアルやってみた。
デジタルオシロスコープで波形、撮ったので、真似してみた。
送信のみ、実装。

シリアルの波形

tera termで「U」を送った。0x55。
9600ボー、パリティなし、ストップ1

007.jpg

写真

unoのD13に、RXをつなぐ。

MVC-008F.JPG

結果

tera termで、受け取った。

image

サンプルコード

start bit を送り、lsbからmsbへ、8個送って、stop bit送るを500msで繰り返す。

void setup()
{
    pinMode(13, OUTPUT);
    digitalWrite(13, HIGH);
}
void loop()
{
    byte data = 'U';
    byte mask = 0x01;
    int i;
    delay(500);
    digitalWrite(13, LOW);
    delayMicroseconds(100);
    for (i = 0; i < 8; i++)
    {
        if (data & mask)
        {
            digitalWrite(13, HIGH);
        }
        else
        {
            digitalWrite(13, LOW);
        }
        delayMicroseconds(100);
        mask <<= 1;
    }
    digitalWrite(13, LOW);
    delayMicroseconds(100);
    digitalWrite(13, HIGH);
}

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0