Herunterladen Inhalt Inhalt Diese Seite drucken

SunFounder Da Vinci Kit Bedienungsanleitung Seite 229

Für den raspberry pi 4 modell b, 3 modell a +, 3 modell b +, 3 modell b, 2 modell b, 1 modell b +, 1 modell a +, zero w and zero
Inhaltsverzeichnis

Werbung

Fah
=
cel
1.8
+32;
*
Konvertieren Sie Grad Celsius in Fahrenheit.
printf("Celsius: %.2f C
Drucken Sie Celsius, Fahrenheit und ihre Einheiten auf dem Display.
Für Python-Sprachbenutzer
Schritt 2: Gehen Sie zum Ordner der Kode.
cd
/home/pi/davinci-kit-for-raspberry-pi/python/
Schritt 3: Führen Sie die ausführbare Datei aus
sudo python3 2.2.2_Thermistor.py
With the code run, the thermistor detects ambient temperature which will be printed on the screen once it finishes the
program calculation. Code
Bemerkung: Sie können den folgenden Code Ändern/Zurücksetzen/ Kopieren/Ausführen/Stoppen. Zuvor müssen
Sie jedoch zu einem Quellcodepfad wie davinci-kit-for-raspberry-pi\\python gehen.
import
RPi.GPIO
as
import
ADC0834
import
time
import
math
def
init():
ADC0834.setup()
def
loop():
while
True:
analogVal
=
Vr
=
5
float(analogVal)
*
Rt
=
10000
temp
=
1/(((math.log(Rt
Cel
=
temp
Fah
=
Cel
*
print
('Celsius:
time.sleep(0.2)
if
__name__
==
'__main__':
init()
try:
loop()
except
KeyboardInterrupt:
ADC0834.destroy()
Code Erklärung
import
math
1.8. 2 Eingabe
Fahrenheit: %.2f
GPIO
ADC0834.getResult()
/
255
Vr
/
(5
-
Vr)
*
/
10000))
-
273.15
1.8
+
32
%.2f
C
Fahrenheit:
F\n", cel, Fah);
/
3950)
+
(1
/
(273.15+25)))
%.2f
F'
%
(Cel, Fah))
SunFounder Da Vinci Kit
225

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis