Einführung in Arduino
1. Sketch
/*
DIGITALEN INPUT LESEN UND IM SERIELLEN MONITOR ANZEIGEN
1. Kabel in »digitalPin 0« stecken
2. Sketch uploaden
3. serieller Monitor starten
4. anderes Ende des Kabels in »Ground« stecken
*/
// festlegen des digitalen pins 0
int digitalPin = 0;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the digital pin an input:
pinMode(digitalPin, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int pinState = digitalRead(digitalPin);
// print out the state of the button:
Serial.println(printState);
delay(1); // delay in between reads for stability
}
2. Sketch
/*
RAUSCHEN (Luft messen):
ANALOGEN INPUT IM SERIELLEN MONITOR ANZEIGEN
1. Sketch uploaden
2. sich dem pin/board nähern etc.
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
}