Tilt sensor(SW-520D) JP: 두 판 사이의 차이

아두위키 : Arduwiki
(새 문서: center|class=coders100 This sensor outputs a HIGH value when tilted. It is modularized, allowing for direct connection to an Arduino. The sensitivity of the tilt detection can be adjusted by manipulating the variable resistor on the product. == '''Specifications''' == * Operating Voltage: 3.3V ~ 5V == '''Required Hardware''' == * Tilt sensor * Arduino UNO * UNO Cable * M-F Cable (3 pieces) == '''Connection''' == Can be connected t...)
 
잔글편집 요약 없음
1번째 줄: 1번째 줄:
[[File:기울기대표이미지1.jpg|center|class=coders100]]
[[File:기울기대표이미지1.jpg|center|class=coders100]]
This sensor outputs a HIGH value when tilted.
このセンサーは傾いたときにHIGH値を出力します。


It is modularized, allowing for direct connection to an Arduino.
モジュール化されており、Arduinoに直接接続することができます。


The sensitivity of the tilt detection can be adjusted by manipulating the variable resistor on the product.
製品の可変抵抗器を操作することで、傾斜検出の感度を調整することができます。




== '''Specifications''' ==
== '''仕様''' ==


* Operating Voltage: 3.3V ~ 5V
* 動作電圧: 3.3V ~ 5V




== '''Required Hardware''' ==
== '''必要なハードウェア''' ==


* Tilt sensor
* 傾斜センサー
* Arduino UNO
* Arduino UNO
* UNO Cable
* UNOケーブル
* M-F Cable (3 pieces)
* M-Fケーブル(3本)




== '''Connection''' ==
== '''接続''' ==
Can be connected to a digital pin other than D7.
D7以外のデジタルピンにも接続可能です。
{| class="wikitable"
{| class="wikitable"
|+
|+
40번째 줄: 40번째 줄:
[[File:Sw520d 회로.png|center|class=coders100]]
[[File:Sw520d 회로.png|center|class=coders100]]


== '''Example Code''' ==
== '''サンプルコード''' ==
Check the execution results on the Serial Monitor. [https://blog.naver.com/gongzipsa/222888559217 Execution video]<syntaxhighlight lang="c++" line="1">
シリアルモニターで実行結果を確認してください。 [https://blog.naver.com/gongzipsa/222888559217 Execution video]<syntaxhighlight lang="c++" line="1">
// Define the tilt sensor pin number
// Define the tilt sensor pin number
#define tilt 7
#define tilt 7
56번째 줄: 56번째 줄:
void loop()
void loop()
{
{
   if(digitalRead(tilt) == 0) // When the tilt sensor output is 0 (balanced state)
   if(digitalRead(tilt) == 0) // 傾斜センサーの出力が0(バランス状態)の場合
   {
   {
     Serial.println("Balanced");
     Serial.println("Balanced");
     delay(1000);
     delay(1000);
   }
   }
   else if(digitalRead(tilt) == 1) // When the tilt sensor output is 1 (tilted state)
   else if(digitalRead(tilt) == 1) // 傾斜センサーの出力が1(傾斜状態)の場合
   {
   {
     Serial.println("Tilted");
     Serial.println("Tilted");

2025년 3월 20일 (목) 17:47 판

このセンサーは傾いたときにHIGH値を出力します。

モジュール化されており、Arduinoに直接接続することができます。

製品の可変抵抗器を操作することで、傾斜検出の感度を調整することができます。


仕様

  • 動作電圧: 3.3V ~ 5V


必要なハードウェア

  • 傾斜センサー
  • Arduino UNO
  • UNOケーブル
  • M-Fケーブル(3本)


接続

D7以外のデジタルピンにも接続可能です。

SW-520D Arduino Uno
D0 D7
GND GND
VCC 5V


サンプルコード

シリアルモニターで実行結果を確認してください。 Execution video

// Define the tilt sensor pin number
#define tilt 7

void setup()
{
  // Set pin 7 as INPUT
  pinMode(tilt, INPUT);
  // Start serial communication
  Serial.begin(9600);
  Serial.println("Serial start");
}

void loop()
{
  if(digitalRead(tilt) == 0) // 傾斜センサーの出力が0(バランス状態)の場合
  {
    Serial.println("Balanced");
    delay(1000);
  }
  else if(digitalRead(tilt) == 1) // 傾斜センサーの出力が1(傾斜状態)の場合
  {
    Serial.println("Tilted");
    delay(1000);
  }
}