Categories
INTERACTON LAB

Arduino code + circuit

byte ledPin = 13; byte switchPin = 3; void setup() {  pinMode(ledPin, OUTPUT);  pinMode(switchPin, INPUT_PULLUP);  Serial.begin(9600); // Initialize serial communication } void loop() {  if (digitalRead(switchPin) == LOW) {    digitalWrite(ledPin, HIGH);    Serial.println("1"); // Send "1" to indicate button pressed  } else {    digitalWrite(ledPin, LOW);    Serial.println("0"); // Send "0" to indicate button not pressed  }  delay(100); // Add a small delay to avoid rapid serial communication }

Leave a Reply

Your email address will not be published. Required fields are marked *