There is my code
/* Prototype final v.03
Date: 17 March 2021
*/
// TRILL SETUP
#include <Trill.h>
Trill trillSensor;
boolean touchActive = false;
// NEOPIXEL SETUP
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
#define LED_PIN 6
#define LED_COUNT 64 // nombre de LEDs
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 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)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
void setup()
{
// TRILL
// Initialise serial and touch sensor
Serial.begin(115200);
int ret = trillSensor.setup(Trill::TRILL_SQUARE);
if (ret != 0)
{
Serial.println("failed to initialise trillSensor");
Serial.print("Error code: ");
Serial.println(ret);
}
else
{
Serial.println("Success initialising trillSensor");
//NEOPIXEL
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif // END of Trinket-specific code
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(255); // Set BRIGHTNESS to about 1/5 (max = 255)
}
}
void loop()
{
// TRILL
delay(50); // Read 20 times per second
trillSensor.read();
// Interactions
if (trillSensor.getNumTouches() == 1) {
// Turn light ON
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, strip.Color(255, 245, 64));
}
}
if (trillSensor.getNumTouches() == 2) {
// Turn light ON
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, strip.Color(255, 245, 64));
}
}
if (trillSensor.getNumTouches() == 3) {
// Turn light ON
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, strip.Color(255, 245, 64));
}
}
if (trillSensor.getNumTouches() == 4) {
// Turn light ON
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, strip.Color(255, 245, 64));
}
}
if (trillSensor.getNumTouches() == 5) {
// Turn light ON
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, strip.Color(255, 245, 64));
}
}
strip.show();
if (trillSensor.getNumTouches() == 4) {
// Turn light ON
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, strip.Color(0, 0, 0));
}
}
if (trillSensor.getNumTouches() == 5) {
// Turn light ON
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, strip.Color(0, 0, 0));
}
}
}