hello_mbot_button
Dies ist eine alte Version des Dokuments!
Hello mBot Button
Quellcode (engl. Sourcecode)
Listing 1:MinimalesProgramm.ino
#include <MeMCore.h>
int PIN_BUTTON = 7; // must be fixed!
int threshold = 500; // Analoger Schwellenwert!
void setup() {
Serial.begin(9600);
pinMode(PIN_BUTTON, INPUT); //Define button pin as input
}
void loop() {
if ( isButtonPressed() ){
Serial.println("Button Pressed");
}
delay(50);
}
bool isButtonPressed(){
if (analogRead(PIN_BUTTON) < threshold)
return true;
return false;
}
Erklärungen zum Quellcode
hello_mbot_button.1738582919.txt.gz · Zuletzt geändert: von torsten.roehl
