Tilt Sensor - Switch Brick
SKU IS120710019 Hersteller iTeadStudio
Nicht auf Lager
1,40 €

Endpreis*, zzgl. Versand

Beschreibung

The tilt-switch twig is the equivalent of a button, and is used as a digital input. When the switch is level it is open, and when tilted, the switch closes. It is wired to the S line.

Connect the + and - to your power supply, the swich close you can read the low leve form S pin, and high level means it's open and in the switch is level.

Programmier Code

const int tiltPin = 3; // the number of the tilt pin
const int buzzerPin =  9;  // the number of the buzzer pin
 
// variables will change:
int tiltState = 0; // variable for reading the tilt status
 
void setup() {
  // initialize the buzzer pin as an output:
  pinMode(buzzerPin, OUTPUT); 
  // initialize the tilt pin as an input:
  pinMode(tiltPin, INPUT);
}
 
void loop(){
  // read the state of the tilt value:
  tiltState = digitalRead(tiltPin);
 
  // check if the tilt is close.
  // if it is, the tiltState is HIGH:
  if (tiltState == HIGH) {
// turn buzzer on:   
digitalWrite(buzzerPin, HIGH); 
  }
  else {
// turn buzzer off:
digitalWrite(buzzerPin, LOW);
  }
}

Specification

Brick TypeSensor Brick
Brick Interface3PIN
Brick Power Supply5V
Board Size37 _ 21 _ 1.6mm
Weight15.00g

Empfohlenes Zusatz Produkt

Frage zum Produkt


Bewertungen (0)

Durchschnittliche Artikelbewertung

Geben Sie die erste Bewertung für diesen Artikel ab und helfen Sie Anderen bei der Kaufenscheidung

Kunden kauften dazu folgende Produkte