rastable/arduino/test/test.ino
2018-11-26 00:49:19 +01:00

70 lines
1.9 KiB
C++

#include <fastspi_types.h>
#include <fastspi.h>
#include <controller.h>
#include <fastled_config.h>
#include <bitswap.h>
#include <chipsets.h>
#include <led_sysdefs.h>
#include <lib8tion.h>
#include <fastled_progmem.h>
#include <fastspi_bitbang.h>
#include <platforms.h>
#include <noise.h>
#include <dmx.h>
#include <hsv2rgb.h>
#include <fastspi_dma.h>
#include <fastled_delay.h>
#include <color.h>
#include <fastpin.h>
#include <FastLED.h>
#include <colorutils.h>
#include <fastspi_nop.h>
#include <colorpalettes.h>
#include <fastspi_ref.h>
#include <pixeltypes.h>
#include <power_mgt.h>
#include <Wire.h>
#define SLAVE_ADDRESS 0x12
#define PIN_LED 13
#define PIN_STRIP 6
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(6, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Wire.begin(SLAVE_ADDRESS);
Wire.onReceive(receiveData);
pinMode(PIN_LED, OUTPUT);
digitalWrite(PIN_LED, LOW);
strip.begin();// initialize strip
strip.show(); // Update all LEDs (= turn OFF, since none of them have been set yet!)
c = strip.Color(255, 0, 0); // define the variable c as RED (R,G,B)
strip.setPixelColor(2, c); // set LED 10 to the color in variable c (red)
strip.show(); // Update all LEDs (= make LED 10 red)
}
void loop() {
delay(10000);
}
void receiveData(int byteCount) {
while(Wire.available()) {
if (1 == Wire.read()) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
}
}