- Supplies: limit switch, Arduino board
- How to connect and the result of serial monitor.
#define limit_switch_pin 2 void setup() { // put your setup code here, to run once: // switch pin setting Serial.begin(9600); pinMode(limit_switch_pin, INPUT); } void loop() { // put your main code here, to run repeatedly: if(digitalRead(limit_switch_pin) == LOW){ Serial.println("Switch close"); }else{ Serial.println("Switch open"); } }
No comments:
Post a Comment