私はこのサイトと Arduino の素晴らしい世界を初めて知りました。Leonardo ボードといくつかの Neopixel LED (WS2812B) で遊んでいます。現在、単一のポットを使用して LED に事前定義された色を設定しようとしていますが、PIR センサーの割り込みもあります。Fastled ライブラリは素晴らしいので使用していますが、現時点では、割り込み部分で立ち往生しているようです。任意のガイダンスをいただければ幸いです。
#include "FastLED.h"
#define NUM_LEDS 3
#define DATA_PIN 6
#define PIR_PIN 2
int PIR_PIN = 0
// These constants won't change:
const int analogPin = A0; // pin that the sensor is attached to
CRGB leds[NUM_LEDS];
void setup() {
// initialize the LED pin as an output:
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
// initialize serial communications:
pinMode(PIR_PIN, INPUT);
attachInterrupt(0, PIR_PIN, CHANGE);
}
void loop() {
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);
if (analogPin < 1000)
{
leds[0] = CRGB::Red;
FastLED.show();// do Thing A
}
else if (analogPin < 500)
{
leds[0] = CRGB::Orange;
FastLED.show();// do Thing B
}
else if (analogPin < 250)
{
leds[0] = CRGB::Green;
FastLED.show();//do fuckity
}
else
{
leds[0] = CRGB::Purple;
FastLED.show();// do Thing C
}
}
void PIN_PIR () {
buttonState = digitalRead(PIR_PIN);
digitalWrite(DATA_PIN, buttonState);
}