라즈베리파이 온도습도 센서
import time
import Adafruit_DHT
class Temp():
def __init__(self):
self.temperPin = 4
self.sensor = Adafruit_DHT.DHT11
def getMyRoomTemp(self):
try:
#
# =================================================================
while True:
h, t = Adafruit_DHT.read_retry (self.sensor,self.temperPin)
if h is not None and t is not None:
print("Temperature = {0:0.1f}*C Humidity = {1:0.1f}%".format(t, h))
else:
print("Read Error !!")
time.sleep(100)
# =================================================================
#
except KeyboardInterrupt as e:
print(e)
finally:
print("end")
if __name__ == "__main__":
o = Temp()
o.getMyRoomTemp()
'arduino_' 카테고리의 다른 글
라즈베리파이 led (0) | 2020.05.18 |
---|---|
four led ver2 (0) | 2017.10.10 |
LED _VER2 FOUR (0) | 2017.10.10 |
four led (0) | 2017.10.10 |
sds011 - 먼지 센서 (0) | 2017.09.21 |
라즈베리파이 led
from RPi import GPIO
import time
class LED():
def __init__(self):
GPIO.setmode(GPIO.BOARD)
self.ledRed = 11
def pinSetup(self):
GPIO.setup(self.ledRed, GPIO.OUT, initial=GPIO.LOW)
def pinOn(self):
try:
while True:
try:
# ===================
# led on !!
# ===================
GPIO.output (self.ledRed, GPIO.HIGH)
except:
print("led on error !!")
beak
else:
time.sleep(0.5)
print("redPing on!!")
try:
# ===================
# led off !!
# ===================
GPIO.output (self.ledRed, GPIO.LOW)
except:
print("led off error !!")
break
else:
time.sleep(0.5)
print("redPing off!!")
except KeyboardInterrupt as e:
print(e)
pass
GPIO.cleanup()
print("cleanup !!")
############################
# program main function
# writer : JunHyeon.kim
############################
if __name__ == "__main__":
o = LED()
o.pinSetup()
o.pinOn()
'arduino_' 카테고리의 다른 글
라즈베리파이 온도습도 센서 (0) | 2020.05.18 |
---|---|
four led ver2 (0) | 2017.10.10 |
LED _VER2 FOUR (0) | 2017.10.10 |
four led (0) | 2017.10.10 |
sds011 - 먼지 센서 (0) | 2017.09.21 |
four led ver2
const int RedPin = 13;
const int BluePin = 12;
const int YellowPin = 11;
const int GreenPin = 10;
void setup() {
// put your setup code here, to run once:
pinMode(RedPin, OUTPUT);
pinMode(BluePin, OUTPUT);
pinMode(YellowPin, OUTPUT);
pinMode(GreenPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
}
'arduino_' 카테고리의 다른 글
라즈베리파이 온도습도 센서 (0) | 2020.05.18 |
---|---|
라즈베리파이 led (0) | 2020.05.18 |
LED _VER2 FOUR (0) | 2017.10.10 |
four led (0) | 2017.10.10 |
sds011 - 먼지 센서 (0) | 2017.09.21 |
LED _VER2 FOUR
const int RedPin = 13;
const int BluePin = 12;
const int YellowPin = 11;
const int GreenPin = 10;
void setup() {
// put your setup code here, to run once:
pinMode(RedPin, OUTPUT);
pinMode(BluePin, OUTPUT);
pinMode(YellowPin, OUTPUT);
pinMode(GreenPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
}
'arduino_' 카테고리의 다른 글
라즈베리파이 led (0) | 2020.05.18 |
---|---|
four led ver2 (0) | 2017.10.10 |
four led (0) | 2017.10.10 |
sds011 - 먼지 센서 (0) | 2017.09.21 |
데이터 사이즈 (0) | 2017.09.21 |
const int RedPin = 13;
const int BluePin = 12;
const int YellowPin = 11;
const int GreenPin = 10;
void setup() {
// put your setup code here, to run once:
pinMode(RedPin, OUTPUT);
pinMode(BluePin, OUTPUT);
pinMode(YellowPin, OUTPUT);
pinMode(GreenPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
for (int i = 0; i < 10; i++)
{
if (i%2 == 0)
{
digitalWrite(11, LOW); // YellowPin
digitalWrite(13, LOW); // RedPin
digitalWrite(10, HIGH); // GreenPin
digitalWrite(12, HIGH); // BluePin
delay(1000); // 1 seconds
}
else
{
digitalWrite(10, LOW); // YellowPin
digitalWrite(12, LOW); // RedPin
digitalWrite(11, HIGH); // GreenPin
digitalWrite(13, HIGH); // BluePin
delay(1000); // 1 seconds
}
}
}
'arduino_' 카테고리의 다른 글
four led ver2 (0) | 2017.10.10 |
---|---|
LED _VER2 FOUR (0) | 2017.10.10 |
sds011 - 먼지 센서 (0) | 2017.09.21 |
데이터 사이즈 (0) | 2017.09.21 |
10개만 출력 (0) | 2016.03.26 |
sds011 - 먼지 센서
참고 사이트 : http://brtech.tistory.com/52
# include <SDS011.h>
float data1 = 0.0;
float data2 = 0.0;
int error;
SDS011 my_sds;
void setup() {
// put your setup code here, to run once:
my_sds.begin(6,7); // RXD, TXD
Serial.begin(9600);
Serial.println("Initialized complete");
}
void loop() {
// put your main code here, to run repeatedly:
error = my_sds.read(&data1, &data2);
if(!error) {
Serial.println("data1: " + String(data1));
Serial.println("data2: " + String(data2));
}
delay(1000); // 1 seconds
}
'arduino_' 카테고리의 다른 글
LED _VER2 FOUR (0) | 2017.10.10 |
---|---|
four led (0) | 2017.10.10 |
데이터 사이즈 (0) | 2017.09.21 |
10개만 출력 (0) | 2016.03.26 |
illumination_sensor (조도센서) (0) | 2016.02.13 |
void setup() {
// 프로그램이 처음 실행될 때 한번만 실행
Serial.begin(9600);
}
void loop() {
// 프로그램이 실행되는 동안 반본적으로 호출
Serial.println("boolean : " + String(sizeof(boolean)));
Serial.println("char : " + String(sizeof(char)));
Serial.println("byte : " + String(sizeof(byte)));
Serial.println("int : " + String(sizeof(int)));
Serial.println("word : " + String(sizeof(word)));
Serial.println("long : " + String(sizeof(long)));
Serial.println("short : " + String(sizeof(short)));
Serial.println("float : " + String(sizeof(float)));
Serial.println("double : " + String(sizeof(double)));
while (1);
}
'arduino_' 카테고리의 다른 글
four led (0) | 2017.10.10 |
---|---|
sds011 - 먼지 센서 (0) | 2017.09.21 |
10개만 출력 (0) | 2016.03.26 |
illumination_sensor (조도센서) (0) | 2016.02.13 |
아놀로그 핀 디지털 핀으로 대체 가능함 (0) | 2016.02.13 |
int result = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
randomSeed(analogRead(0));
}
void loop() {
// put your main code here, to run repeatedly:
if(result == 0){
int i;
for(i=1; i<=10; i++){
delay(1000);
Serial.println( random(66,100));
}
result+=1;
}
}
'arduino_' 카테고리의 다른 글
sds011 - 먼지 센서 (0) | 2017.09.21 |
---|---|
데이터 사이즈 (0) | 2017.09.21 |
illumination_sensor (조도센서) (0) | 2016.02.13 |
아놀로그 핀 디지털 핀으로 대체 가능함 (0) | 2016.02.13 |
랜덤으로 30개의 숫자를 만들고 짝수일때 빨간 홀수일때 블루 (0) | 2016.02.13 |
illumination_sensor (조도센서)
방에 불을 끄면 어두워서 --> led On
const int led_yellow_pin = 13;
const int illumination_sensor = A0;
int value;
void setup() {
// put your setup code here, to run once:
pinMode(led_yellow_pin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
value = analogRead(illumination_sensor);
Serial.println(value);
if ( value < 100) {
digitalWrite(led_yellow_pin, HIGH);
} else {
digitalWrite(led_yellow_pin, LOW);
}
}
'arduino_' 카테고리의 다른 글
데이터 사이즈 (0) | 2017.09.21 |
---|---|
10개만 출력 (0) | 2016.03.26 |
아놀로그 핀 디지털 핀으로 대체 가능함 (0) | 2016.02.13 |
랜덤으로 30개의 숫자를 만들고 짝수일때 빨간 홀수일때 블루 (0) | 2016.02.13 |
(smart toilet) 논문 (0) | 2016.01.13 |
아놀로그 핀 디지털 핀으로 대체 가능함
//----------------------------------------
const int ultra1_trig_PLUS_pin = 13;
const int ultra1_echo_PLUS_pin = 12;
const int ultra2_trig_SUB_pin = A0;
const int ultra2_echo_SUB_pin = A1;
int number = 0;
//----------------------------------------
void setup() {
// put your setup code here, to run once:
// $ ultra1_ $
pinMode(ultra1_trig_PLUS_pin, OUTPUT); // pinNumber: 13
pinMode(ultra1_echo_PLUS_pin, INPUT); // pinNumber: 12
// $ ultra2_ $
pinMode(ultra2_trig_SUB_pin, OUTPUT); // pinNumber: A0
pinMode(ultra2_echo_SUB_pin, INPUT); // pinNumber: A1
//
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
// $ ULTRA1 ----------------------------------------------------------------
digitalWrite(ultra1_trig_PLUS_pin, LOW);
delayMicroseconds(2);
digitalWrite(ultra1_trig_PLUS_pin, HIGH);
delayMicroseconds(10);
digitalWrite(ultra1_trig_PLUS_pin, LOW);
long distance_plus = pulseIn(ultra1_echo_PLUS_pin, HIGH)/58.2;
//$ ULTRA2 ----------------------------------------------------------------
digitalWrite(ultra2_trig_SUB_pin, LOW);
delayMicroseconds(2);
digitalWrite(ultra2_trig_SUB_pin, HIGH);
delayMicroseconds(10);
digitalWrite(ultra2_trig_SUB_pin, LOW);
long distance_sub = pulseIn(ultra2_echo_SUB_pin, HIGH)/58.2;
if (distance_plus < 10) {
Serial.print("distance_plus -> ");
Serial.print(distance_plus);
Serial.println(" cm");
number++;
Serial.print("number is ");
Serial.println(number);
} else { //distance_plus >= 10
if (distance_sub < 10) {
Serial.print("distance_sub -> ");
Serial.print(distance_sub);
Serial.println(" cm");
number--;
Serial.print("number is ");
Serial.println(number);
}
}
}
'arduino_' 카테고리의 다른 글
10개만 출력 (0) | 2016.03.26 |
---|---|
illumination_sensor (조도센서) (0) | 2016.02.13 |
랜덤으로 30개의 숫자를 만들고 짝수일때 빨간 홀수일때 블루 (0) | 2016.02.13 |
(smart toilet) 논문 (0) | 2016.01.13 |
조도센서---> led_Green (0) | 2015.09.08 |