ArduinoとリードスイッチでLEDをON/OFFする -電磁開閉器(マグネットドアスイッチ)-

ArduinoとリードスイッチでLEDをON/OFFする

 

はじめに

arduinoとリードスイッチでスイッチング処理のやり方を備忘録として纏める。

注意として、リードスイッチを5Vにつなげて磁気を近づけてはいけない。電流が逆流?する?

 

ひつようなもの

aruduino uno r3 ×1

リードスイッチ ×1

(ドアコンタクトアラーム,SODIAL(R)5xMC-38 Nr. 10-25 mm 磁気ドア接触リード 切り替え 白)

赤LED ×1

 

 

つなぎかた

※誤字 D3ではなくD2です。

スケッチ

ここのMagnetic Door Sensor and Arduinoサイトを参考にした。


const int switchPin = 2;//スイッチ接続ピン
const int ledPin = 13;//LED接続ピン

void setup(){
  Serial.begin(115200);
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(switchPin, HIGH);
}

void loop(){
  if(digitalRead(switchPin) == LOW){//磁気が離れると
    digitalWrite(ledPin, LOW);
    Serial.println("OFF");
  }
  else{//磁気を近づけると
    digitalWrite(ledPin, HIGH);
    Serial.println("ON");
  }
  delay(1000);
}

※ソースは<pre>と<code>で作成した

 

完成

完成動画

 

まとめ

・リードスイッチで処理ができた。

ArduinoとリードスイッチでLEDをON/OFFする -電磁開閉器(マグネットドアスイッチ)-” に対して1件のコメントがあります。

  1. estakyfeene より:

    google free casino slot games vegas slots online

  2. alareedia より:

    usa casinos no deposit free welcome bonus online casino gambling

  3. Unsurgesini より:

    hollywood casino play4fun casino slots

  4. usephonee より:

    free slots no registration no download free slot games with no download

  5. WeepTeeksNonsem より:

    casino games no download no registration play free win real cash

  6. Ruibreenetift より:

    100 best usa casinos with best codes plainridge casino

  7. PilyncVeile より:

    slot machines for home entertainment online gambling for real money

  8. Kayaphcinance より:

    free games for casino slots hollywood 300 free slots no download

  9. TretgovaVorgo より:

    free online slots no download no registration free las vegas slot machines

  10. alareedia より:

    real casino slot machine games scatter slots

  11. Zellquome より:

    slot machines for home entertainment poker games

  12. estakyfeene より:

    us online casinos for real money free casino blackjack

  13. Offimally より:

    free slots no download no registration jackpot magic slots

  14. Antidesed より:

    free casino games online real casino

  15. estakyfeene より:

    online casino no deposit free welcome bonus zone online casino

  16. alatocculfush より:

    hollywood casino online slots online slot games

  17. LeDSerneineniox より:

    us online casinos for real money cashman casino slots

  18. alatocculfush より:

    online casinos for us players casino bonus

  19. WeepTeeksNonsem より:

    online casino no deposit free welcome bonus free slots vegas world

  20. Attevonnangaf より:

    free games for casino slots hollywood foxwoods casino online

  21. Offimally より:

    real casino slot machine games hollywood casino

  22. Antidesed より:

    free online slots no download no registration gold fish casino slots

  23. SmommachoollA より:

    casino games no download no registration borgata online casino

  24. Offimally より:

    free online bingo vegas world lady luck

  25. Kayaphcinance より:

    play free casino games online chumba casino

  26. TretgovaVorgo より:

    online casino slots no download poker games

  27. FupDuhfaulp より:

    vegas world free slots games zone online casino

  28. smuperiamutuall より:

    hollywood casino online slots free vegas slots casino

  29. LeDSerneineniox より:

    us online casinos for real money slots online free

  30. Antidesed より:

    las vegas casinos slots machines cashman casino slots free

  31. usephonee より:

    download free casino games bonus casino

  32. LeDSerneineniox より:

    free slots with bonus rounds no download caesar casino online slot games

  33. estakyfeene より:

    turning stone online slots casino blackjack

  34. Zellquome より:

    play free mr cashman slots scatter slots

  35. Kayaphcinance より:

    play casino games for cash play free slot

  36. LeDSerneineniox より:

    biggest no deposit welcome bonus heart of vegas slots

  37. Antidesed より:

    free slot games download full version free slots games

  38. Offimally より:

    sugarhouse casino online free slot play

  39. estakyfeene より:

    free slot games with no download doubledown casino

  40. Zellquome より:

    heart of vegas free slots vegas slots free

  41. TretgovaVorgo より:

    da vinci diamonds free online slots free online casino

  42. usephonee より:

    no deposit win real cash free casino

  43. Attevonnangaf より:

    slots free spins no registration cashman casino slots

  44. estakyfeene より:

    caesar casino free slots games gsn casino

  45. FupDuhfaulp より:

    las vegas casinos slots machines vegas world slots

  46. alareedia より:

    free casino slots with bonus konami free slots

  47. Attevonnangaf より:

    best online gambling sites for real money las vegas free penny slots

  48. alareedia より:

    best online gambling sites for real money free slots online no download

  49. Attevonnangaf より:

    no deposit games online for real cash pop slots

  50. PilyncVeile より:

    lady luck casino free games online slot games

  51. Antidesed より:

    online casino real money online casino

  52. LeDSerneineniox より:

    free slots with bonus rounds no download vegas casino online

  53. usephonee より:

    free slots with bonus rounds no download free vegas world slots

  54. estakyfeene より:

    free casino games with bonus konami free slots

  55. PilyncVeile より:

    best place to gamble in vegas casinos near me

  56. Antidesed より:

    100 best usa casinos with best codes slots for free

  57. Attevonnangaf より:

    bigfish casino online games vegas free slots

  58. SmommachoollA より:

    free slots with bonus rounds no download free casino blackjack games

  59. Attevonnangaf より:

    empire city casino online free play free slots

  60. estakyfeene より:

    caesar casino free slots games casino free

  61. SmommachoollA より:

    free online slots no download no registration free slots with no download or registration

  62. Ruibreenetift より:

    free online slots vegas world hollywood slots

  63. TretgovaVorgo より:

    play free win real cash gsn casino

  64. alatocculfush より:

    free casino games no download pechanga casino

  65. SmommachoollA より:

    play free casino games online usa online casino

  66. Attevonnangaf より:

    play free casino slots now poker games

  67. FupDuhfaulp より:

    zone online casino bingo games hypercasinos

  68. Attevonnangaf より:

    casino games no download no registration us online casinos for real money

  69. WeepTeeksNonsem より:

    no download no registration slots casinos near me

  70. smuperiamutuall より:

    free games online no download vegas slots

  71. Attevonnangaf より:

    free slot games with no download dakota sioux casino

  72. TretgovaVorgo より:

    free slot games download full version online casinos real money

  73. estakyfeene より:

    vegas casino free online games mirrorball slots

  74. SmommachoollA より:

    da vinci diamonds free online slots free slots vegas world

  75. Offimally より:

    vegas casino free slot games gsn casino

  76. TretgovaVorgo より:

    play slots for real money united states three rivers casino

  77. Zellquome より:

    real casino slot machine games free casino blackjack

  78. TretgovaVorgo より:

    play free casino slots now online casino

  79. Kayaphcinance より:

    free casino games slot machines hallmark casino online

  80. Zellquome より:

    usa casinos no deposit free welcome bonus cleopatra slots

  81. FupDuhfaulp より:

    totally free slots no download best online casinos

  82. Lonleaceclier より:

    las vegas casinos slots machines zone online casino

  83. Offimally より:

    no download no registration slots vegas slots casino

  84. Unsurgesini より:

    play free vegas casino games casinos in iowa

  85. SmommachoollA より:

    vegas world free games online slots online betting sites

  86. alareedia より:

    free online games that pay real money best online casinos

  87. Lonleaceclier より:

    biggest no deposit welcome bonus casino bonus codes

  88. avemnartema より:

    best free slots vegas world mgm online casino

  89. estakyfeene より:

    jackpot magic slots download posh casino online

  90. TretgovaVorgo より:

    free casino games no registration no download free slots online no download

  91. Attevonnangaf より:

    online casino games free free slots

  92. Lonleaceclier より:

    hollywood casino free slots online vegas casino games

  93. swepDyncSleessy より:

    free online slots no download no registration play real casino slots free

  94. alareedia より:

    atari vegas world free slots online slots free

  95. Ruibreenetift より:

    empire city casino online free free slots vegas

  96. Antidesed より:

    msn games zone online casino buffalo slots

  97. WeepTeeksNonsem より:

    300 free slots no download no registration old vegas slots

  98. Attevonnangaf より:

    free slots no download no registration zeus free slots just for fun no money

  99. FupDuhfaulp より:

    play real casino slots free zone online casino

  100. Zellquome より:

    vegas casino free online games slot games free

  101. TretgovaVorgo より:

    absolutely free casino slots games play slots for real money

  102. Offimally より:

    free casino for fun only slot games free

  103. estakyfeene より:

    online casino no deposit free welcome bonus free coins slotomania

  104. Unsurgesini より:

    casino games slots free pch slots

  105. Zellquome より:

    no deposit bonus codes for usa players free penny slot machine games

  106. alareedia より:

    best online gambling sites for real money free online slots games

  107. estakyfeene より:

    free casino games no download online gambling

  108. Ruibreenetift より:

    free games for casino slots hollywood free vegas casino games

  109. Kayaphcinance より:

    hollywood casino free slots online mgm online casino

  110. Antidesed より:

    free slots no registration no download simslots free slots

  111. Attevonnangaf より:

    free slots with bonus rounds no download casino blackjack

  112. Unsurgesini より:

    online casino real money slots games

  113. smuperiamutuall より:

    vegas world free slots games casino slots

  114. TretgovaVorgo より:

    no download no registration slots slots casino games

  115. FupDuhfaulp より:

    free slots online no download no registration quick hit slots

  116. avemnartema より:

    absolutely free casino slots games dakota sioux casino

  117. estakyfeene より:

    no deposit games online for real cash zone online casino games

  118. alareedia より:

    play free slot machines with bonus spins monopoly slots

  119. Antidesed より:

    free full casino games download slots lounge

  120. avemnartema より:

    most popular free casino slots new online casinos

  121. estakyfeene より:

    free slots online no download no registration hearts of vegas free slots

  122. Zellquome より:

    maryland live casino online big fish casino

  123. steskmabkem より:

    best time to play slot machines free slot games for fun

  124. WeepTeeksNonsem より:

    free games online no download no registration free online slots no download

  125. LeDSerneineniox より:

    heart of vegas casino game casino bonus

  126. Kayaphcinance より:

    play free slot machines with bonus spins 100 most popular free slots

  127. FupDuhfaulp より:

    vegas casino games slots free best online casino

  128. Ruibreenetift より:

    hollywood casino free online games casino games free slots