아두이노 - NEO LED BT모드

자료실

아두이노 - NEO LED BT모드

소프트웨어과 1 20,835 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 아두이노 초음파센서 댓글+2 소프트웨어과 2022.06.02 62543
열람중 아두이노 - NEO LED BT모드 댓글+1 소프트웨어과 2022.06.03 20836
46 2019 상업경진대회 기출문제(비지니스 프로그래밍) 최고관리자 2020.05.25 1727
45 에디트플러스 응용프로그래밍 2019.06.17 1598
44 C++ cin cout 댓글+5 소프트웨어과 2023.03.14 1575
43 응용프로그래밍 화면 구현 책pdf 소프트웨어과 2021.04.23 1503
42 탭메뉴 예제 최고관리자 2021.03.11 1406
41 2015 경기도 상업경진대회 프로그래밍 기출문제 5번 소프트웨어과 2019.05.17 1373
40 2020 상업경진 경제골든벨 문제지 최고관리자 2021.04.12 1336
39 2014 경기도 상업정보 경진대회 프로그래밍 기출문제 3번 소프트웨어과 2019.05.17 1289
38 putty 다운로드 소프트웨어과 2019.06.17 1254
37 CSS 메뉴연습 소프트웨어과 2021.05.24 1101
36 2015 경기도 상업경진대회 프로그래밍 기출문제 1번 소프트웨어과 2019.05.17 1100
35 풀이: 2014 경기도 상업정보 경진대회 프로그래밍 기출문제 3번 소프트웨어과 2019.05.17 1091
34 풀이: 2014 경기도 상업경진대회 프로그래밍 문제 4번 소프트웨어과 2019.05.17 1077
33 2014 경기도 상업정보 경진대회 프로그래밍 기출문제 1번 소프웨에어과 2019.05.17 1067
32 2018 상업경진대회 기출문제(비지니스 프로그래밍) 최고관리자 2020.05.25 1066
31 풀이: 2014 경기도 상업정보 경진대회 프로그래밍 기출문제 1번 소프트웨어과 2019.05.17 1059
30 풀이: 2015 경기도 상업경진대회 프로그래밍 기출문제 1번 소프트웨어과 2019.05.17 1058
29 2014 경기도 상업정보 경진대회 프로그래밍 기출문제 2번 소프트웨어과 2019.05.17 1054
Category
반응형 구글광고 등
State
  • 현재 접속자 60 명
  • 오늘 방문자 2,880 명
  • 어제 방문자 3,422 명
  • 최대 방문자 3,491 명
  • 전체 방문자 530,225 명
  • 전체 게시물 6,918 개
  • 전체 댓글수 132 개
  • 전체 회원수 31 명
Facebook Twitter GooglePlus KakaoStory NaverBand