Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

VCC: Tilkobling til strøm (3,3-5 V)

Testing

For å teste hvordan den fungerer kan du koble den opp og lese av inngangene på Arduinoen. Bruk gjerne eksempelkoden fra GitHub som lar deg lese av både analog og digital inngang samtidig.

Code Block
languagecpp
titleRead Digital and Analog Example
const int analogIn = A0; // The analog pin we will use
const int digitalIn = 2; // The digital pin we will use

void setup() {
  // Start communication wirh console
  Serial.begin(9600);
  // Set input mode for digial pin
  pinMode(digitalIn, INPUT);
}

void loop() {
  // Read digital input and tell result to user.
  Serial.print("Digital: ");
  if (digitalRead(digitalIn) == HIGH) {
    Serial.print("High\t");
  } else {
    Serial.print("Low\t");
  }
  
  // Read analog input and tell result to user.
  Serial.print("Analog: ");
  Serial.println(analogRead(analogIn));
  // Wait for 1 second before next read
  delay(1000);
}