LK-Button1: Unterschied zwischen den Versionen
Aus Linkerkit.de
Zeile 8: | Zeile 8: | ||
==Codebeispiel Arduino== | ==Codebeispiel Arduino== | ||
− | <pre class="brush:cpp"> | + | <pre class="brush:cpp">const int ButtonPin=9; |
− | + | void setup() { | |
− | const int | + | pinMode(ButtonPin, INPUT); |
− | + | Serial.begin(9600); | |
− | + | ||
− | void setup(){ | + | |
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | void loop (){ | + | void loop() { |
− | + | int sensorValue = digitalRead(ButtonPin); | |
− | + | if(sensorValue==1) | |
− | + | { | |
− | + | Serial.println("High"); | |
− | + | } | |
− | + | else | |
− | + | { | |
− | + | Serial.println("Low"); | |
− | } </pre> | + | } </pre> |
==Codebeispiel Raspberry Pi== | ==Codebeispiel Raspberry Pi== | ||
− | <pre class="brush:py"> </pre> | + | <pre class="brush:py"> </pre> |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Version vom 19. August 2016, 11:42 Uhr
Inhaltsverzeichnis
Bild
Technische Daten / Kurzbeschreibung
Linker Kit Platine mit 1 Druckknopf
Codebeispiel Arduino
const int ButtonPin=9; void setup() { pinMode(ButtonPin, INPUT); Serial.begin(9600); } void loop() { int sensorValue = digitalRead(ButtonPin); if(sensorValue==1) { Serial.println("High"); } else { Serial.println("Low"); }