Regarding Teensy 3.6 and FASTled (and pulling out hair!) ...

Regarding Teensy 3.6 and FASTled (and pulling out hair!) … I’m trying to write my own lightsaber code and have the audio working off the built in sdcard very well using mixers etc, and now want to move on to using the WS2812 LED strings, but if I’m correct there isn’t any official support for the 3.6 in FASTled yet? However, I have read that someone had this working by using a different branch? I’ve tried everything I can find but cannot get the sketch to compile as it’s giving “Invalid pin specified” errors. Are there any magicians among you that have got this to work or can point me in the right direction please? I’m still somewhat newbie at this so may be missing something very obvious.

Work in progress sketch below with FASTled parts commented out:

#include <EEPROMex.h>
#include <EEPROMvar.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <OneButton.h>
#include <SoftTimers.h>

//#include <FastLED.h>

#define NUM_LEDS 122

#define SDCARD_CS_PIN BUILTIN_SDCARD
#define PWR_BUTTON_PIN A0
#define PWR_BUTTON_GND A1
#define BATT_MONITOR_PIN A2
#define GYRO_INT A8
#define BLADE_POWER_PIN A9
#define LED_DATA_PIN A10
#define COLOR_ORDER RGB
#define FLASH_COLOR 160
#define BLADE_TEMP_PROFILE Halogen // Tungsten100W

int color_counter = 0;

int BLADE_COLOR = color_counter;

int blade_color_modified = 0;
int BLADE_FLICKER_STRENGTH = 180;
int BLADE_FLICKER_TYPE = 0;
int SWING_SENSITIVITY = 20;
int CLASH_SENSITIVITY = 30;
int PLAYBACK_VOLUME = 22;
int SYSTEM_VOLUME = 20;
int BLADE_INTENSITY = 180;
int BLADE_HUE = 255;

const int MPU_addr=0x68; // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
int randNumber;
int saber_active = 0;
int settings_enabled = 0;
int settings_type;
int settings_numerator = 0;
int settings_led_num = 1;
int button_timer = 300;
int level_numerator = 0;
int blaster = 0;
int lockup = 0;
int nextSetting = 1;
int blade_powered = 0;

int EEPROM_address_blade_color = 0;
int EEPROM_address_blade_flicker = 1;
int EEPROM_address_blade_swing = 2;
int EEPROM_address_blade_clash = 3;
int EEPROM_address_blade_volume = 4;
int EEPROM_address_blade_flicker_type = 5;
int EEPROM_address_blade_intensity = 6;

//CRGB leds[NUM_LEDS];
OneButton button(PWR_BUTTON_PIN, true);
SoftTimer pulseTimer;
SoftTimer blasterTimer;
SoftTimer lockupTimer;
SoftTimer clashTimer;

AudioPlaySdWav playSdWav1;
AudioPlaySdWav playSdWav2;
AudioMixer4 mixer1;
AudioOutputAnalog dac1;
AudioConnection patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord2(playSdWav2, 0, mixer1, 1);
AudioConnection patchCord3(mixer1, dac1);

void setup() {
Serial.begin(9600);
delay(500);

pinMode(PWR_BUTTON_GND, OUTPUT);
digitalWrite(PWR_BUTTON_GND, LOW);
pinMode(BLADE_POWER_PIN, OUTPUT);
pinMode(BATT_MONITOR_PIN, INPUT);
pinMode(GYRO_INT, INPUT_PULLUP);

button.setClickTicks(button_timer);
button.attachClick(buttonClick);
button.attachDoubleClick(buttonDoubleClick);
button.attachLongPressStart(buttonLongPress);

//FastLED.setBrightness(BLADE_INTENSITY);
//FastLED.setTemperature(BLADE_TEMP_PROFILE);
//FastLED.setMaxPowerInVoltsAndMilliamps(5,1000);
//FastLED.addLeds<WS2812B, LED_DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);//.setCorrection( TypicalLEDStrip );

getEEpromSettings();

mixer1.gain(0, 0.5);
mixer1.gain(1, 0.5);

AudioMemory(8);
if (!(SD.begin(SDCARD_CS_PIN))) {
while(1){
Serial.println(“Unable to access the SD card”);
delay(500);
}
}

}

void loop() {
delay(3);
button.tick();
saberHum();
}

/ MEMORY FUNCTIONS /

void getEEpromSettings(){
byte EEpromVal;
EEpromVal = EEPROM.read(EEPROM_address_blade_color);
if(EEpromVal < 300){ // first reading
color_counter = EEpromVal;
BLADE_COLOR = EEpromVal;
}
delay(20);
EEpromVal = EEPROM.read(EEPROM_address_blade_flicker);
if(EEpromVal < 500){ // first reading
BLADE_FLICKER_STRENGTH = EEpromVal;
}
delay(20);
EEpromVal = EEPROM.read(EEPROM_address_blade_swing);
if(EEpromVal < 100){ // first reading
SWING_SENSITIVITY = EEpromVal;
}
delay(20);
EEpromVal = EEPROM.read(EEPROM_address_blade_clash);
if(EEpromVal < 100){ // first reading
CLASH_SENSITIVITY = EEpromVal;
}
EEpromVal = EEPROM.read(EEPROM_address_blade_volume);
if(EEpromVal < 255){ // nothing stored detection
PLAYBACK_VOLUME = EEpromVal;
}
delay(20);
EEpromVal = EEPROM.read(EEPROM_address_blade_flicker_type);
if(EEpromVal < 255){ // nothing stored detection
BLADE_FLICKER_TYPE = EEpromVal;
}
delay(20);
EEpromVal = EEPROM.read(EEPROM_address_blade_intensity);
if(EEpromVal < 255){ // nothing stored detection
BLADE_INTENSITY = EEpromVal;
}
delay(20);
}

void storeEEpromSettings(){
// store color in EEPROM
if(blade_color_modified) color_counter --; // need to remove 1 only if we were setting the blade color
EEPROM.update(EEPROM_address_blade_color, BLADE_COLOR);
while (!EEPROM.isReady()) {delay(1);}
// store flicker in EEPROM
EEPROM.update(EEPROM_address_blade_flicker, BLADE_FLICKER_STRENGTH);
while (!EEPROM.isReady()) {delay(1);}
// store swing in EEPROM
EEPROM.update(EEPROM_address_blade_swing, SWING_SENSITIVITY);
while (!EEPROM.isReady()) {delay(1);}
// store clash in EEPROM
EEPROM.update(EEPROM_address_blade_clash, CLASH_SENSITIVITY);
while (!EEPROM.isReady()) {delay(1);}
// store volume in EEPROM
EEPROM.update(EEPROM_address_blade_volume, PLAYBACK_VOLUME);
while (!EEPROM.isReady()) {delay(1);}
// store flicker type in EEPROM
EEPROM.update(EEPROM_address_blade_flicker_type, BLADE_FLICKER_TYPE);
while (!EEPROM.isReady()) {delay(1);}
// store blade intensity in EEPROM
EEPROM.update(EEPROM_address_blade_intensity, BLADE_INTENSITY);
while (!EEPROM.isReady()) {delay(1);}
}

/ BUTTON FUNCTIONS /

void buttonClick(){
if(!saber_active){
playFile(“poweron.wav”, 1);
saber_active = 1;
}else{
playFile(“blaster.wav”, 1);
}
}

void buttonDoubleClick(){
if(saber_active){
saber_active = 0;
playFile(“poweroff.wav”, 1);
}
}

void buttonLongPress(){
if(saber_active){
playFile(“lockup.wav”, 1);
}
}

void saberHum(){
if(saber_active){
if(!playSdWav2.isPlaying()){
playSdWav2.play(“hum.wav”);
}
}
}

void playFile(const char *filename, int wait){
if(playSdWav2.isPlaying()){
playSdWav2.stop();
}
playSdWav1.play(filename);
delay(5);
if(wait){
while (playSdWav1.isPlaying());
}
}

1170e4ded45e1506cf1ab1cf99384319.jpeg

Get rid of the A - FastLED pin definitions are just the PIN number - you shouldn’t be using things like A10 or D23 - just 10 or 23.

Thanks I’ll try that

Did that work for you?

Im considering buying a teensy. Need to drive a 32x32 led matrix but i dont have a controller that can handle it

I haven’t yet mate, but I will report back when I do

I have tried this and can confirm that the sketch now compiled without error. Many thanks @Daniel_Garcia for pointing this out, I would never have thought of it. Most odd though, as I used FASTled with a Pro Micro, identical code and the LED strip worked ok. Is this something specific to the Teensy?

No - it’s more an inconsistency in arruino platforms - sometimes the Dxx or Axx are #defines to just integer pins that are mapped properly, other times they map to something else entirely. You’ll notice that the example code never uses them - just the digits for pins :slight_smile:

Nice! OK mate, thanks for your help with this, all the best :slight_smile: