에듀이노-아두이노 전문 교육쇼핑몰 에듀이노-코딩교육 전문 쇼핑몰
뒤로가기

묻고답하기

제목

lcd에 표시 되는 값이 선명하지 않습니다. high, low 값은 다른 용도로 쓰고 있는데 방법이 있을까요

작성자 1809967352@k(ip:)

작성일 2021-07-28

조회 26

평점 0점  

추천 추천하기

내용

안녕하세요. 너무 모르는것이 많습니다. 검색을 아무리해도 찾아 볼수없어서...문의드립니다.

아두이노+ LCD + 2 Push buttons 에서 구현한것을

NODEMCU에서는 핀D2를 LCD도 써야 하고, 버튼도 써야해서 arduino uno에서 2, 3에 연결했던 것을

nodeMCU에서는 , GPIO12 = D6, GPIO13 = D7 로 연결 했습니다.

업로드하고, 작동은 되는데 LCD에 숫자가 CLEAR하지 않게 표시됩니다.  


코드는 아래와 같습니다.

//Compatible with the Arduino IDE 1.0

//Library version:1.1


#include <Wire.h>

#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 20, 4);  // set the LCD address to 0x27 for a 20 chars and 4 line display


// this constant won't change:


const int  Down_buttonPin = 12;    // the pin that the pushbutton is attached to  GPIO12 = D6

const int  Up_buttonPin = 13;        // the pin that the pushbutton is attached to  GPIO13 = D7


// Variables will change:


int buttonPushCounter = 0;   // counter for the number of button presses

int up_buttonState = 0;         // current state of the up button

int up_lastButtonState = 0; // previous state of the up button

bool aPress = true; 


int down_buttonState = 0;         // current state of the up button

int down_lastButtonState = 0;     // previous state of the up button

bool bPress = false;


void setup()

{

  Serial.begin(9600);

  Wire.begin();


  // Wire.begin(SDA, SCL);            // NODEMCU/ESP default ist D2 = 4 = SDA ; D1 = 5 = SCL

  //Wire.begin(4, 5);              // NODEMCU geht

  //Wire.begin(D5, D6);           


  

  pinMode( Up_buttonPin , INPUT_PULLUP);

  pinMode( Down_buttonPin , INPUT_PULLUP);

  lcd.begin(); 

 //   lcd.init();                      // initialize the lcd

  // Print a message to the LCD.

  lcd.backlight();

 // lcd.noBacklight();

  lcd.setCursor(0,0);

  lcd.print("Please Select:");

  lcd.setCursor(2,1);

  lcd.print(buttonPushCounter);

}


void loop()

{

   checkUp();

   checkDown();


   if( bPress){

       bPress = false;

      lcd.setCursor(2,1);

      lcd.print("               ");

      lcd.setCursor(2,1);

      lcd.print(buttonPushCounter);

   }

   else{

    aPress = true;

    lcd.setCursor(2,1);

    lcd.print("               ");

    lcd.setCursor(2,1);

    lcd.print(buttonPushCounter);

   }

}


void checkUp()

{

  up_buttonState = digitalRead(Up_buttonPin);

 // compare the buttonState to its previous state


  if (up_buttonState != up_lastButtonState) {


    // if the state has changed, increment the counter


    if (up_buttonState == LOW) {

        bPress = true;

      // if the current state is HIGH then the button went from off to on:


      buttonPushCounter++;


      Serial.println("on");

      Serial.print("number of button pushes: ");

      Serial.println(buttonPushCounter);

    } else {

      // if the current state is LOW then the button went from on to off:

      Serial.println("off");

    }

    // Delay a little bit to avoid bouncing

    delay(50);

  }


  // save the current state as the last state, for next time through the loop


  up_lastButtonState = up_buttonState;


}


void checkDown()

{

  down_buttonState = digitalRead(Down_buttonPin);

  // compare the buttonState to its previous state

  if (down_buttonState != down_lastButtonState) {

    // if the state has changed, increment the counter

    if (down_buttonState == LOW) {

       bPress = true;


      // if the current state is HIGH then the button went from off to on:


      buttonPushCounter--;


      Serial.println("on");

      Serial.print("number of button pushes: ");

      Serial.println(buttonPushCounter);


    } else {


      // if the current state is LOW then the button went from on to off:

      Serial.println("off");

    }


    // Delay a little bit to avoid bouncing

    delay(50);

  }


  // save the current state as the last state, for next time through the loop

  down_lastButtonState = down_buttonState;

}


첨부파일

비밀번호
수정

비밀번호 입력후 수정 혹은 삭제해주세요.

댓글목록

  • 작성자 사령관

    작성일 2021-07-28

    평점 0점  

    스팸글 node MCU는 3.3V지원인데 LCD는 5V동작이예요 !

    LCD가 전원공급이 원활하지않으면, 밝기가 어두워진다던지, 특정구간이 출력이 안되는 현상들이 랜덤으로 나타나게 됩니다!

    별도의 회로구성을 하는방법과, 3.3V동작의 LCD를 사용하시는것을 추천드려요 !!

    정확하게 모든것을 확인할 수 는 없지만 제가 보기에는 전원공급에대한 문제로 생각됩니다 ~
  • 작성자 Ironman

    작성일 2021-07-28

    평점 0점  

    스팸글 보드보시면 Vin핀에 별도 5V전원을 공급해주세요!
댓글 수정

이름

비밀번호

내용

/ byte

수정 취소

비밀번호 :

확인 취소

댓글 입력

이름

비밀번호

내용

/ byte

평점

왼쪽의 문자를 공백없이 입력하세요.

에게만 댓글 작성 권한이 있습니다.

댓글 입력

이름

비밀번호

내용

/ byte

왼쪽의 문자를 공백없이 입력하세요.

에게만 댓글 작성 권한이 있습니다.

관련 글 보기

고객센터

    1670-9626

  • 팩스.063-902-6678
  • 이메일.eduino@robodyne.co.kr
  • Kakao. 에듀이노
  • 운영시간 : AM 10:00 ~ PM 16:30
  • 점심시간 : PM 12:00 - PM 13:00 토/일/공휴일 휴무
  • 고객센터 연결하기
입금계좌
  • 예금주: (주)로보다인시스템
  • 국민. 754801-01-760296
  • 농협. 301-0234-1423-01
  • IBK기업은행. 506-080015-01-016
배송 안내
  • 배송 방법 : 택배
  • 배송 지역 : 전국지역
  • 배송 비용 : 조건부 무료 : 주문 금액 100,000원 미만일 때 배송비 3,000원을 추가합니다.
  • 배송 기간 : 1일 ~ 2일
  • 배송 안내 :
    - 제주도, 산간벽지나 도서지방은 별도의 추가금액을 지불하셔야 하는 경우가 있습니다.
    고객님께서 주문하신 상품은 입금 확인후 배송해 드립니다. 다만, 상품종류에 따라서 상품의 배송이 다소 지연될 수 있습니다.
교환/반품 안내
교환 및 반품이 가능한 경우
- 상품을 공급 받으신 날로부터 7일이내 단, 가전제품의
  경우 포장을 개봉하였거나 포장이 훼손되어 상품가치가 상실된 경우에는 교환/반품이 불가능합니다.
- 공급받으신 상품 및 용역의 내용이 표시.광고 내용과
  다르거나 다르게 이행된 경우에는 공급받은 날로부터 3월이내, 그사실을 알게 된 날로부터 30일이내

교환 및 반품이 불가능한 경우
- 고객님의 책임 있는 사유로 상품등이 멸실 또는 훼손된 경우. 단, 상품의 내용을 확인하기 위하여
  포장 등을 훼손한 경우는 제외
- 포장을 개봉하였거나 포장이 훼손되어 상품가치가 상실된 경우
  (예 : 가전제품, 식품, 음반 등, 단 액정화면이 부착된 노트북, LCD모니터, 디지털 카메라 등의 불량화소에
  따른 반품/교환은 제조사 기준에 따릅니다.)
- 고객님의 사용 또는 일부 소비에 의하여 상품의 가치가 현저히 감소한 경우 단, 화장품등의 경우 시용제품을
  제공한 경우에 한 합니다.
- 시간의 경과에 의하여 재판매가 곤란할 정도로 상품등의 가치가 현저히 감소한 경우
- 복제가 가능한 상품등의 포장을 훼손한 경우
  (자세한 내용은 고객만족센터 1:1 E-MAIL상담을 이용해 주시기 바랍니다.)

※ 고객님의 마음이 바뀌어 교환, 반품을 하실 경우 상품반송 비용은 고객님께서 부담하셔야 합니다.
  (색상 교환, 사이즈 교환 등 포함)
«
»