Skip to content
Snippets Groups Projects
Commit 53e94d69 authored by Myres's avatar Myres
Browse files

Define servoshutter behaviour without switch (or switch in open state).

parent 887c9249
No related branches found
No related tags found
No related merge requests found
# CHANGELOG
## 1.2.0
### Changed
- Switch uses internal pullup for defined behavior.
## 1.1.0
### Added
......
......@@ -10,7 +10,7 @@ o? queries the current output state (independent whether it has been set via com
"l" returns the current state and manual mode (tab separated)
****************************
*/
const String version = "1.1.0"; // Version of this script
const String version = "1.2.0"; // Version of this script
// Servo setup
#include <Servo.h>
......@@ -31,8 +31,8 @@ void setup()
// Read initial state
delay(100);
val = analogRead(switchPin);
if ( val >= 512 ){
pinMode(switchPin, INPUT_PULLUP);
if ( !digitalRead(switchPin) ){
state = -2;
}
}
......@@ -97,13 +97,13 @@ void loop()
}
if ( manual ){
val = analogRead(switchPin);
val = digitalRead(switchPin);
// If the analog value changed from the known state or known switch, change shutter.
if(val >= 512 && (state == 0 || state == -1))
if( !val && (state == 0 || state == -1))
{
openShutter();
}
else if(val < 512 && (state == 1 || state == -2))
else if( val && (state == 1 || state == -2))
{
closeShutter();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment