아두이노 - NEO LED BT모드

자료실

아두이노 - NEO LED BT모드

소프트웨어과 1 20,813 2022.06.03 11:08

#include <SoftwareSerial.h>        // 소프트웨어 시리얼 라이브러리를 포함

#include <Adafruit_NeoPixel.h>   // 네오픽셀 라이브러리를 포함

#define PIN 7

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(2, PIN, NEO_GRB + NEO_KHZ800);

SoftwareSerial bluetooth(2, 3);    // 디지털 2,3번 핀을 시리얼 통신 핀으로 설정

void setup() {

  pixels.begin(); 

  pixels.show();

  bluetooth.begin(9600);

}

byte r = 0, g = 0, b = 0;

void loop() {

  if (bluetooth.available() > 2) {       // 만약 2개가 넘는 데이터를 받는다면

    r = bluetooth.read();                    // r, g, b에 각각의 데이터를 대입

    g = bluetooth.read();

    b = bluetooth.read();

    bluetooth.flush();                         // 데이터가 전송완료될 때까지 대기

    pixels.setPixelColor(0, pixels.Color(r, g, b));     // 1번째 네오픽셀 설정

    pixels.setPixelColor(1, pixels.Color(r, g, b));     // 2번째 네오픽셀 설정

    pixels.show();

  }

}

Comments

소프트웨어과 2022.06.03 11:16
BT없이 단순 LED켜기

#include <Adafruit_NeoPixel.h>
#define PIN 7
#define LEDNUM 2
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LEDNUM, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
}
void loop() {
  strip.begin();
  strip.show();
  strip.setPixelColor(0, 255, 0,0);
  strip.setPixelColor(1, 0, 0, 255);
  delay(4000);
  strip.begin();
  strip.show();
  strip.setPixelColor(0, 0, 0, 255);
  strip.setPixelColor(1, 0, 0, 255);
  delay(4000);
  strip.begin();
  strip.show();
  strip.setPixelColor(0, 0,100, 0);
  strip.setPixelColor(1, 0, 255, 255);
  delay(4000);
  strip.begin();
  strip.show();
  strip.setPixelColor(0, 255, 255, 0);
  strip.setPixelColor(1, 0, 100, 50);
  delay(4000);
  strip.begin();
  strip.show();
  strip.setPixelColor(0, 255, 255, 255);
  strip.setPixelColor(1, 100, 255, 0);
  delay(4000);
  strip.begin();
  strip.show();
  strip.setPixelColor(0, 255, 255, 255);
  strip.setPixelColor(1, 255, 255, 255);
  delay(4000);
}
번호 제목 글쓴이 날짜 조회
48 2024년도 한국사능력검정 운영 계획 소프트웨어과 03.12 69
47 javascript 계산기 소프트웨어과 2023.04.20 320
46 C++ cin cout 댓글+5 소프트웨어과 2023.03.14 1413
45 이 사이트는 안전하지 않습니다. 소프트웨어과 2023.03.08 401
44 아두이노 RC카 소프트웨어과 2022.06.29 652
43 아두이노-LCD 소프트웨어과 2022.06.09 780
열람중 아두이노 - NEO LED BT모드 댓글+1 소프트웨어과 2022.06.03 20814
41 아두이노 초음파센서 댓글+2 소프트웨어과 2022.06.02 62510
40 사회봉사 활동 계획서 소프트웨어과 2021.11.05 794
39 학부모동의서(자격증) 소프트웨어과 2021.09.13 858
38 코드론 시뮬레이터 소프트웨어과 2021.07.01 959
37 코드론 미니 - 드라이버 소프트웨어과 2021.07.01 847
36 CSS 메뉴연습 소프트웨어과 2021.05.24 1083
35 응용프로그래밍 화면 구현 책pdf 소프트웨어과 2021.04.23 1478
34 교외체험학습 규정 및 신청서 양식 최고관리자 2021.04.20 851
33 2020 상업경진 경제골든벨 문제지 최고관리자 2021.04.12 1315
32 2020 상업경진 컴퓨터그래픽 문제지 최고관리자 2021.04.12 910
31 2020-시도 비즈니스 프로그래밍 문제지 최고관리자 2021.04.12 957
30 제10회 비즈니스 프로그래밍 문제지(2020) 최고관리자 2021.04.12 868
29 탭메뉴 예제 최고관리자 2021.03.11 1388
Category
반응형 구글광고 등
State
  • 현재 접속자 56 명
  • 오늘 방문자 2,936 명
  • 어제 방문자 3,224 명
  • 최대 방문자 3,297 명
  • 전체 방문자 493,906 명
  • 전체 게시물 6,891 개
  • 전체 댓글수 131 개
  • 전체 회원수 31 명
Facebook Twitter GooglePlus KakaoStory NaverBand