質問編集履歴

5

誤記訂正

2019/11/25 06:58

投稿

raspypy
raspypy

スコア247

test CHANGED
File without changes
test CHANGED
@@ -60,16 +60,6 @@
60
60
 
61
61
  def read_temp():
62
62
 
63
- global df_c
64
-
65
- df_c = pd.read_csv('/home/pi/count.csv', names=['year', 'month', 'day', 'hour', 'minute', 'temperature'])
66
-
67
-
68
-
69
- #カウント
70
-
71
- y_bool = df_c['year'] == 0
72
-
73
63
  global prev_y_sum
74
64
 
75
65
  prev_y_sum = y_bool.sum()
@@ -80,35 +70,9 @@
80
70
 
81
71
  def LED():
82
72
 
83
- prev_y_sum = 0
84
-
85
- while True:
86
-
87
- y_bool = df_c['year'] == 0
88
-
89
- y_sum = y_bool.sum()
90
-
91
- while y_sum == prev_y_sum:
92
-
93
- GPIO.output(19, GPIO.HIGH)
94
-
95
- sleep(1.0)
96
-
97
- GPIO.output(19, GPIO.LOW)
98
-
99
- sleep(1.0)
100
-
101
- else:
102
-
103
- break
104
-
105
- prev_y_sum = y_bool.sum()
106
-
107
73
  print (y_sum)
108
74
 
109
75
  print (prev_y_sum)
110
-
111
-
112
76
 
113
77
 
114
78
 

4

プログラムを更新しました。

2019/11/25 06:58

投稿

raspypy
raspypy

スコア247

test CHANGED
File without changes
test CHANGED
@@ -88,7 +88,7 @@
88
88
 
89
89
  y_sum = y_bool.sum()
90
90
 
91
- if y_sum == prev_y_sum:
91
+ while y_sum == prev_y_sum:
92
92
 
93
93
  GPIO.output(19, GPIO.HIGH)
94
94
 

3

プログラムの更新

2019/11/25 06:16

投稿

raspypy
raspypy

スコア247

test CHANGED
File without changes
test CHANGED
@@ -48,6 +48,16 @@
48
48
 
49
49
  ```python
50
50
 
51
+ def setup_led():
52
+
53
+ GPIO.setmode(GPIO.BCM)
54
+
55
+ GPIO.setup(19, GPIO.OUT)
56
+
57
+ GPIO.output(19, GPIO.LOW)
58
+
59
+
60
+
51
61
  def read_temp():
52
62
 
53
63
  global df_c
@@ -63,8 +73,6 @@
63
73
  global prev_y_sum
64
74
 
65
75
  prev_y_sum = y_bool.sum()
66
-
67
- print (prev_y_sum)
68
76
 
69
77
 
70
78
 
@@ -95,6 +103,8 @@
95
103
  break
96
104
 
97
105
  prev_y_sum = y_bool.sum()
106
+
107
+ print (y_sum)
98
108
 
99
109
  print (prev_y_sum)
100
110
 

2

プログラム全体を掲載しました。

2019/11/25 06:01

投稿

raspypy
raspypy

スコア247

test CHANGED
File without changes
test CHANGED
@@ -72,6 +72,8 @@
72
72
 
73
73
  def LED():
74
74
 
75
+ prev_y_sum = 0
76
+
75
77
  while True:
76
78
 
77
79
  y_bool = df_c['year'] == 0
@@ -96,6 +98,26 @@
96
98
 
97
99
  print (prev_y_sum)
98
100
 
101
+
102
+
103
+
104
+
105
+ if __name__ == '__main__':
106
+
107
+ try:
108
+
109
+ setup_led()
110
+
111
+ read_temp()
112
+
113
+ LED()
114
+
115
+ except KeyboardInterrupt:
116
+
117
+ pass
118
+
119
+ GPIO.cleanup()
120
+
99
121
  ```
100
122
 
101
123
 

1

プログラムの誤記修正

2019/11/25 05:57

投稿

raspypy
raspypy

スコア247

test CHANGED
File without changes
test CHANGED
@@ -60,11 +60,11 @@
60
60
 
61
61
  y_bool = df_c['year'] == 0
62
62
 
63
- global y_sum
63
+ global prev_y_sum
64
64
 
65
- y_sum = y_bool.sum()
65
+ prev_y_sum = y_bool.sum()
66
66
 
67
- print (y_sum)
67
+ print (prev_y_sum)
68
68
 
69
69
 
70
70
 
@@ -78,7 +78,7 @@
78
78
 
79
79
  y_sum = y_bool.sum()
80
80
 
81
- if prev_y_sum == y_sum:
81
+ if y_sum == prev_y_sum:
82
82
 
83
83
  GPIO.output(19, GPIO.HIGH)
84
84