마이크로비트+스마트 화분

마이크로비트+스마트 화분

Makerist 1 1649

#include <Wire.h>
#include <MicroBit.h>


// 토양수분센서 핀 정의
const int soilMoisturePin = A0;
// 펌프 모터 제어 핀 정의
const int motorIN1 = 2; // 모터 제어 핀 1
const int motorIN2 = 3; // 모터 제어 핀 2


MicroBit uBit;


void setup() {
  // 마이크로비트 초기화
  uBit.init();
  
  // 펌프 모터 제어 핀을 출력으로 설정
  pinMode(motorIN1, OUTPUT);
  pinMode(motorIN2, OUTPUT);
}


void loop() {
  // 토양수분센서에서 값을 읽어옴
  int soilMoistureValue = analogRead(soilMoisturePin);
  
  // 토양 수분 값에 따라 다른 표정을 설정하고 펌프 모터를 제어함
  if (soilMoistureValue < 300) {
    uBit.display.scroll("Sad");
    // 펌프 모터를 작동시켜 물을 분사함
    digitalWrite(motorIN1, HIGH);
    digitalWrite(motorIN2, LOW);
    delay(1000); // 1초 동안 작동시킴 (조절 가능)
  } else {
    uBit.display.scroll("Happy");
    // 펌프 모터를 정지함
    digitalWrite(motorIN1, LOW);
    digitalWrite(motorIN2, LOW);
  }


  // 잠시 대기
  delay(1000); // 1초 대기 (조절 가능)
}

1 Comments
Makerist 2024.04.14 09:50  
#include <Arduino.h>

// 토양수분센서 핀 정의
const int moisture_pin = A0;

// L9110S 모터 드라이버 핀 정의
const int motor_in1 = 8;
const int motor_in2 = 9;

// 수분 임계값 정의
const int moisture_threshold = 500;

// 워터펌프 작동 상태
bool pump_on = false;
Category
반응형 구글광고 등
State
  • 현재 접속자 49 명
  • 오늘 방문자 2,883 명
  • 어제 방문자 3,313 명
  • 최대 방문자 4,586 명
  • 전체 방문자 674,775 명
  • 전체 게시물 25,584 개
  • 전체 댓글수 36 개
  • 전체 회원수 22 명
Facebook Twitter GooglePlus KakaoStory KakaoTalk NaverBand