Aktionen

16.05. Einführung in Arduino: Unterschied zwischen den Versionen

Aus exmediawiki

(Die Seite wurde neu angelegt: „=Einführung in Arduino= ==1. Sketch== <pre> /* DIGITALEN INPUT LESEN UND IM SERIELLEN MONITOR ANZEIGEN 1. Kabel in »digitalPin 0« stecken 2. Sketch uplo…“)
 
 
(2 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 42: Zeile 42:
 
RAUSCHEN (Luft messen):
 
RAUSCHEN (Luft messen):
 
ANALOGEN INPUT IM SERIELLEN MONITOR ANZEIGEN
 
ANALOGEN INPUT IM SERIELLEN MONITOR ANZEIGEN
 +
 +
1. Sketch uploaden
 +
2. sich dem pin/board nähern etc.
  
 
  */
 
  */
Zeile 59: Zeile 62:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
[[Category:Programmierung]]
 +
[[Category:Arduino]]
 +
[[Category:HowTo]]

Aktuelle Version vom 29. Juni 2019, 15:49 Uhr

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);
}