#inclode <Servo.h>
#define powerLEDPin 2
#define addChipPin 3
#define openPin 4
#define resetChipsPin 5
unsigned long lastPress;
void addChip()
{
Serial.println("Adding chip");
}
void openClose()
{
static bool state = false;
state = !state;
if (state)
{
Serial.println("Opening");
}
else
{
Serial.println("Closing");
}
}
void reset()
{
Serial.println("Removing all added microchips");
}
bool checkVal(int pin)
{
return digitalRead(pin);
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(9000);
pinMode(powerLEDPin, OUTPUT);
pinMode(addChipPin, INPUT_PULLUP);
pinMode(openPin, INPUT_PULLUP);
pinMode(resetChipsPin, INPUT_PULLUP);
lastPress = 0;
}
void loop()
{
// put your main code here, to run repeatedly:
digitalWrite(powerLEDPin, HIGH);
bool openState = !digitalRead(openPin);
bool addChipState = !digitalRead(addChipPin);
bool resetState = !digitalRead(resetChipsPin);
if (addChipState && millis() - lastPress > 300)
{
addChip();
lastPress = millis();
}
if (openState && millis() - lastPress > 300)
{
openClose();
lastPress = millis();
}
if (resetState && millis() - lastPress > 300)
{
reset();
lastPress = millis();
}
}