Last active
August 9, 2018 01:33
-
-
Save alvesoaj/0b6662f5a0cc9b561001e41e98daded0 to your computer and use it in GitHub Desktop.
Conecting a Reed Switch with Arduino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * AJ Alves (aj.alves@zerokol.com) | |
| */ | |
| const int REED_SWITCH_PIN = 3; // Reed Switch Pin | |
| void setup() { | |
| Serial.begin(9600); // Init serial 9600 | |
| pinMode(REED_SWITCH_PIN, INPUT); // Set pin as INPUT | |
| } | |
| void loop() { | |
| int rsState = digitalRead(REED_SWITCH_PIN); // Reading pin value | |
| if (rsState == HIGH) { | |
| Serial.println("I can feel the magnet!"); | |
| } else { | |
| Serial.println("Where is the magnet?"); | |
| } | |
| delay(1000); // Wait for 1 second | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment