Back to Parent

int ledPin = D2;
int buttonPin = D3;
int fsrPin = A0;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  pinMode(fsrPin, INPUT);
}

void loop() {
  int buttonState = digitalRead(buttonPin);
  int fsrValue = analogRead(fsrPin);

   bool isButtonPressed = (buttonState == LOW);
  bool isFsrPressed = (fsrValue > 5);

  if (isButtonPressed && isFsrPressed) {
    digitalWrite(ledPin, HIGH); 
  } else {
    digitalWrite(ledPin, LOW); 
  }

  delay(100);
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0