Hi Mike
I have tried your suggestions and trying to eject the suggested code - the first 2 blocks seemed to pass without errors on verification, but on the last one (the replace loop function i get this error
"expected primary-expression before "==" token
Maybe i have not placed the lines corretly regarding to the brackets ?
This is the code that fails the last block:
// Super-basic UNTZtrument MIDI example. Maps buttons to MIDI note
// on/off events; this is NOT a sequencer or anything fancy.
// Requires an Arduino Leonardo w/TeeOnArdu config (or a PJRC Teensy),
// software on host computer for synth or to route to other devices.
#include <Wire.h>
#include <Adafruit_Trellis.h>
#include <Adafruit_UNTZtrument.h>
#include "MIDIUSB.h"
#define LED 13 // Pin for heartbeat LED (shows code is working)
#define CHANNEL y +8// MIDI channel number
#ifndef HELLA
// A standard UNTZtrument has four Trellises in a 2x2 arrangement
// (8x8 buttons total). addr[] is the I2C address of the upper left,
// upper right, lower left and lower right matrices, respectively,
// assuming an upright orientation, i.e. labels on board are in the
// normal reading direction.
Adafruit_Trellis T[4];
Adafruit_UNTZtrument untztrument(&T[0], &T[1], &T[2], &T[3]);
const uint8_t addr[] = { 0x70, 0x71,
0x72, 0x73 };
#else
// A HELLA UNTZtrument has eight Trellis boards...
Adafruit_Trellis T[8];
Adafruit_UNTZtrument untztrument(&T[0], &T[1], &T[2], &T[3],
&T[4], &T[5], &T[6], &T[7]);
const uint8_t addr[] = { 0x70, 0x71, 0x72, 0x73,
0x74, 0x75, 0x76, 0x77 };
#endif // HELLA
// For this example, MIDI note numbers are simply centered based on
// the number of Trellis buttons; each row doesn't necessarily
// correspond to an octave or anything.
#define WIDTH ((sizeof(T) / sizeof(T[0])) * 2)
#define N_BUTTONS ((sizeof(T) / sizeof(T[0])) * 16)
#define LOWNOTE ((128 - N_BUTTONS) / 2)
uint8_t heart = 0; // Heartbeat LED counter
unsigned long prevReadTime = 0L; // Keypad polling timer
byte noteArray[8][8] = {
{36, 43, 48, 50, 51, 53, 55, 58},
{36, 43, 48, 50, 51, 53, 55, 58},
{36, 43, 48, 50, 51, 53, 55, 58},
{36, 43, 48, 50, 51, 53, 55, 58},
{36, 43, 48, 50, 51, 53, 55, 58},
{36, 43, 48, 50, 51, 53, 55, 58},
{36, 43, 48, 50, 51, 53, 55, 58},
{36, 43, 48, 50, 51, 53, 55, 58} };
boolean notePlaying[8][8]; // this is an array to store if a note is playing
void setup()
{
// clear note playing array
for(byte i=0; i<8; i++){
for(byte j=0; i<8; j++){
notePlaying[i][j] = false;
}
}
pinMode(LED, OUTPUT);
#ifndef HELLA
untztrument.begin(addr[0], addr[1], addr[2], addr[3]);
#else
untztrument.begin(addr[0], addr[1], addr[2], addr[3],
addr[4], addr[5], addr[6], addr[7]);
#endif // HELLA
// Default Arduino I2C speed is 100 KHz, but the HT16K33 supports
// 400 KHz. We can force this for faster read & refresh, but may
// break compatibility with other I2C devices...so be prepared to
// comment this out, or save & restore value as needed.
#ifdef ARDUINO_ARCH_SAMD
Wire.setClock(400000L);
#endif
#ifdef __AVR__
TWBR = 12; // 400 KHz I2C on 16 MHz AVR
#endif
untztrument.clear();
untztrument.writeDisplay();
}
void noteOn(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOn);
MidiUSB.flush();
}
void noteOff(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOff);
MidiUSB.flush();
}
void loop() {
unsigned long t = millis();
if((t - prevReadTime) >= 20L) { // 20ms = min Trellis poll time
if(untztrument.readSwitches()) { // Button state change?
for(uint8_t i=0; i<N_BUTTONS; i++) { // For each button...
// Get column/row for button, convert to MIDI note number
uint8_t x, y, note;
untztrument.i2xy(i, &x, &y);
note = noteArray[y][x];
// if a key is pressed and a note is not playing turn it on
if(untztrument.justPressed(i) && notePlaying[y][x]) == false) {
noteOn(CHANNEL, note, 100);
notePlaying[y][x] = true;
untztrument.setLED(i);
}
// if a key is pressed and a note is already playing turn it off
if(untztrument.justPressed(i) && notePlaying[y][x]) == true) {
noteOff(CHANNEL, note, 0);
notePlaying[y][x] = false;
untztrument.clrLED(i);
}
}
untztrument.writeDisplay();
}
prevReadTime = t;
digitalWrite(LED, ++heart & 32); // Blink = alive
}
}
have i inserted/replaced your cod the right places ?
Regarding all the #def stuff inside the setup function - i can only say that i was in the origional Hello World example from which this all is build (see earlier post)
best regards
Henning