OS/Banana Pi /BPI-Bit
BPI-Bit : 전면 LED 사용하기
파란크리스마스
2019. 2. 5. 22:45
728x90
출처
BPI-Bit : 전면 LED 사용하기
BPI-Bit 전면 LED는 RGB 제어가 가능한 LED로 여러가지 색표현이 가능 모듈로 비슷한 보드인 micro:bit가 단색으로 표현 되는 것보다 개선 되었다고 볼 수 있습니다.
BPI-Bit : 전면 LED 배열
NeoPixel_Bus 라이브러리 추가 (https://github.com/Makuna/NeoPixelBus)
메누 [툴] - [라이브러리 관리] 선택
검색창에 [NeoPixel_Bus]로 검색하고, [설치] 버튼을 선택해서, 라이브러리 설치
예제 실행
메뉴 [파일] - [예제] - [NeoPixelBus by Makuna] - [NeoPixelTest] 선택
BPI-Bit 전면 LED에 맞게 예제 수정
수정전
const uint16_t PixelCount = 4; // this example assumes 4 pixels, making it smaller will cause a failure const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
수정후
const uint16_t PixelCount = 25; // this example assumes 4 pixels, making it smaller will cause a failure const uint8_t PixelPin = 4; // make sure to set this to the correct pin, ignored for Esp8266
setup 함수에 내용 추가
void setup()
{
#define LED_POWER 2
pinMode(LED_POWER, OUTPUT);
digitalWrite(LED_POWER, HIGH);
Serial.begin(115200);
while (!Serial); // wait for serial attach
실행 결과
실제로 보면 색상의 변환가 잘 보이지만, 너무 밝아서 사진에는 잘 보이지 않습니다.
예제2
#include <NeoPixelBus.h> // WS2812 config const uint16_t PixelCount = 25; const uint8_t PixelPin = 4; NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin); #define colorSaturation 32 // LED 조명을 정의 #define ledPower 2 // 빨강과 검정색을 정의 RgbColor red(colorSaturation, 0, 0); RgbColor black(0); void setup() { pinMode(ledPower, OUTPUT); digitalWrite(ledPower, HIGH); // 라이브러리 초기화 strip.Begin(); // 发送数据,默认每个点的颜色为0,所以初始的每个点都是不亮的 strip.Show(); } void loop() { strip.SetPixelColor(0, red); strip.Show(); delay(100); strip.SetPixelColor(0, black); strip.Show(); delay(100); }
예제2 실행
728x90