Arduino 入門學習筆記5 按鍵控制鐳射發生器
阿新 • • 發佈:2018-11-11
程式碼
/**********************************************/ const int keyPin = 13; //the "s" of relay module attach to const int laserPin = 7; /**********************************************/ void setup() { pinMode(laserPin, OUTPUT); //initialize relay as an output pinMode(keyPin, INPUT); } /***********************************************/ void loop() { boolean Value=digitalRead(keyPin); if(Value==HIGH){ digitalWrite(laserPin, LOW); //disconnect the relay }else digitalWrite(laserPin, HIGH); //Close the relay } /*************************************************/