LoginSignup
9
10

More than 5 years have passed since last update.

2015-10-26 python > 1秒ごとの処理 > while True: / time.sleep(1)

Last updated at Posted at 2015-10-26

DHT11の温度、湿度データをのちのちグラフ化したい。

とりあえず1秒ごとに取得するため、whileとtime.sleep()を使う。

timer.py
#!/usr/bin/env python
import time

while True:
    print "Hello"
    time.sleep(1)

print "Hello"の部分にDHT11からの読取り処理を実装する。

cronでやってもよさそうだけど、pythonコードで対応。

9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10