antitheft159 commited on
Commit
b381782
·
verified ·
1 Parent(s): 3916c4c

Upload heggdyrvolt_195.py

Browse files
Files changed (1) hide show
  1. heggdyrvolt_195.py +47 -0
heggdyrvolt_195.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """heggdyrVolt .195
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1nPlLySI66MOAQvscw3IRtOh-MjYncxQ3
8
+ """
9
+
10
+ import LCD1602
11
+ import RPi.GPIO as GPIO
12
+ import dht11
13
+ import time
14
+ GPIO.setmode(GPIO.BCM)
15
+ myDHT=dht11.DHT11(pin=17)
16
+ LCD1602.init(0x27,1)
17
+ buttonPin=21
18
+ GPIO.setup(buttonPin,GPIO.IN,pull_up_down=GPIO.PUD_UP)
19
+ buttonState=1
20
+ buttonStateOld=1
21
+ tempMode=1
22
+ try:
23
+ while True:
24
+ buttonState=GPIO.input(buttonPin):
25
+ if buttonState==1 and buttonStateOld==0:
26
+ tempMode = not tempMode
27
+ print(tempMode)
28
+ buttonStateOld=buttonState
29
+ result=myDHT.read()
30
+ tempC=result.temperature
31
+ tempF=tempC*1.8+32
32
+ hum=result.humidity
33
+ if result.humidity
34
+ if tempMode==True:
35
+ LCD1602.write(0,0,'Temp: ')
36
+ LCD1602.write(6,0,str(tempF))
37
+ LCD1602.write(11,0, ' F')
38
+ LCD1602.write(0,1, 'Humidity: ')
39
+ LCD1602.write(10,1,str(hum))
40
+ LCD1602.write(14,1,'%')
41
+ if tempMode==False:
42
+ LCD1602.write(0,0,'Temp: ')
43
+ LCD1602.write(6,str(tempC))
44
+ LCD1602.write(11,0,' C')
45
+ LCD1602.write(0,1,'Humidity: ')
46
+ LCD1602.write(10,1,str(hum))
47
+ LCD1602.write(14.1,'%')