Another Arduino drum sequencer with minimum hardware drumseq81212 (with schematic)

preview_player
Показать описание
Another Arduino drum sequencer with minimum hardware (schematic and code included). The interface is composed of two rotary encoders with switch and a 128x64 I2C OLED display. The display presents a grid with twelve rows x eight columns, rows are ticks, subdivisions of a beat, columns are tracks, each pattern can have a maximum of twelve beats. Rotary encoders are used to navigate through the grid coordinates. The X encoder switch is used to choose between Cursor, Write, or Beat mode. In Cursor mode the selected rectangular slot on the grid is highlighted by thicker lines. When the cursor passes over an actived slot (On) the slot is erased (Off). In Write mode a filled square is drawn inside the next selected slot on the grid, indicating it is On. In Beat mode the X encoder is used to select which beat will be edited, while the Y encoder is used to set the pattern size (beats per measure). The Y encoder switch selects four modes: Edit, Tempo, Play, and Load. In Edit mode, both X and Y encoders are used to navigate the grid and create or edit a pattern, as described earlier. In Tempo mode the Y encoder sets the sequencer BPM (Beats Per Minute). Entering Play mode starts playing the current pattern. Load mode allows the Y encoder to select and load preset patterns previously stored in the Arduino internal EEPROM. The right side of the display shows BPM tempo and the current modes. The left side shows the row numbers, which beat is being edited, the pattern size (beats per measure) and preset number. Each track fires a gate using eight Arduino pins and also sends MIDI notes through TX pin (channel 10, GM drum notes 35, 38, 42, 46, 45, 50, 64, 76). I am using the MIDI output to control an analog drum module, the eight gates are serving as LED drivers. A ninth LED (dual) serves as the metronome beat indicator. This version has some improvements over the earlier one: each pattern can have a maximum of 144 steps divided in twelve beats. Pattern is still arranged in a bi-dimensional array, this time a 12x12 array containing the twelve beats and twelve subdivisions, the eight tracks are represented as the bits in a byte (kind of a bitmap). The clock now is more robust, using TimerOne library instead of the currentMillis previousMillis approach. There is no OLED activity during play. Code is a bit less messy (it is in the video comments).Libraries do all the hard work: Luni64 Encoder Tool, Adafruit_SSD1306 and GFX, Paul Stoffregen's TimerOne, EEPROM and Wire. I just connected the dots.Hardware:- Arduino Nano.- One 128x64 I2C OLED, connected to Arduino GND, +5V, SCL (A5) and SDA (A4).- Two rotary encoders with switch, the Y encoder terminal connections: A to Arduino pin 4, B to pin 2, C to GND, one switch terminal to pin 6, the other to GND. The X encoder terminal connections: A to Arduino pin 5, B to pin 3, C to GND, one switch terminal to pin 7,- Eight red LEDs, cathode to ground, anode to Arduino pins 8,9,10,11,12, A0,A1,A2 through current limiting resistors (below).- Eight 1K resistors limiting current (5mA) to the red LEDs.- One dual color LED (green and red), common cathode to GND, green to Arduino pin A3 through 680R resistor, red to pin 13 through 680R resistor.- Two 680R resistors, mentioned above.- Two 220R resistors for the MIDI out connector, next.- One 5 pin DIN female connector (MIDI), pin 5 connected to Arduino TX pin through a 220R resistor, pin 4 to +5V through another 220R resistor. Pin 2 and shield connected to GND.- One 100µF/10V electrolytic capacitor connected to +5V and GND.Power supply can be through USB, or a battery or PSU connected to Vin pinand GND. Voltage connected to Vin should be equal or greater than 7V and less than 12V.In order to use the track outputs as gates to directly control non MIDIthings, the red LEDs should be removed, keeping the 1K resistors. Theoutputs will be 0V off, +5V on, this will work with most modular synththings.
Join this channel:

Thanks for watching.
Рекомендации по теме
Комментарии
Автор

Code Part 01 :
/*
* Another Arduino drum sequencer with minimum hardware. The interface is
* composed of two rotary encoders with switch and a 128x64 I2C OLED display.
* The display presents a grid with twelve rows x eight columns, rows are
* "ticks", subdivisions of a beat, columns are tracks, each pattern can have
* a maximum of twelve beats. Rotary encoders are used to navigate through
* the grid coordinates.
* The X encoder switch is used to choose between Cursor, Write, or Beat mode.
* In Cursor mode the selected rectangular slot on the grid is highlighted by
* thicker lines. When the cursor passes over an activated slot (On) the slot is
* erased (Off).
* In Write mode a filled square is drawn inside the next selected slot on the
* grid, indicating it is On.
* In Beat mode the X encoder is used to select which beat will be edited, while
* the Y encoder is used to set the pattern size (beats per measure).
* The Y encoder switch selects four modes: Edit, Tempo, Play, and Load.
* In Edit mode, both X and Y encoders are used to navigate the grid and create
* or edit a pattern, as described earlier.
* In Tempo mode the Y encoder sets the sequencer BPM (Beats Per Minute).
* Entering Play mode starts playing the current pattern.
* Load mode allows the Y encoder to select and load preset patterns previously
* stored in the Arduino internal EEPROM.
* The right side of the display shows BPM tempo and the current modes.
* The left side shows the row numbers, which beat is being edited,
* the pattern size (beats per measure) and preset number.
* Each track fires a gate using eight Arduino pins and also sends MIDI notes
* through TX pin (channel 10, GM drum notes 35, 38, 42, 46, 45, 50, 64, 76).
* I am using the MIDI output to control an analog drum module, the eight
* gates are serving as LED drivers.
* A ninth LED (dual) serves as the metronome beat indicator.
*
* This version has some improvements over the earlier one: each pattern can
* have a maximum of 144 steps divided in twelve beats. Pattern is still
* arranged in a bi-dimensional array, this time a 12x12 array containing the
* twelve beats and twelve subdivisions, the eight tracks are represented as
* the bits in a byte (kind of a bitmap). The clock now is more robust, using
* TimerOne library instead of the currentMillis previousMillis approach.
* There is no OLED activity during play. Code is a bit less messy (it is in
* the video comments).
*
* Libraries do all the hard work: Luni64 Encoder Tool, Adafruit_SSD1306 and GFX,
* Paul Stoffregen's TimerOne, EEPROM and Wire. I just connected the dots.
*
* Hardware:
* - Arduino Nano.
* - One 128x64 I2C OLED, connected to Arduino GND, +5V, SCL (A5) and SDA (A4).
* - Two rotary encoders with switch, the Y encoder terminal connections:
* A to Arduino pin 4, B to pin 2, C to GND, one switch terminal to pin 6,
* the other to GND. The X encoder terminal connections:
* A to Arduino pin 5, B to pin 3, C to GND, one switch terminal to pin 7,
* - Eight red LEDs, cathode to ground, anode to Arduino pins 8, 9, 10, 11, 12,
* A0, A1, A2 through current limiting resistors (below).
* - Eight 1K resistors limiting current (5mA) to the red LEDs.
* - One dual color LED (green and red), common cathode to GND, green to
* Arduino pin A3 through 680R resistor, red to pin 13 through 680R resistor.
* - Two 680R resistors, mentioned above.
* - Two 220R resistors for the MIDI out connector, next.
* - One 5 pin DIN female connector (MIDI), pin 5 connected to Arduino TX pin
* through a 220R resistor, pin 4 to +5V through another 220R resistor. Pin
* 2 and shield connected to GND.
* - One 100µF/10V electrolytic capacitor connected to +5V and GND.
*
* Power supply can be through USB, or a battery or PSU connected to Vin pin
* and GND. Voltage connected to Vin should be >= 7V <= 12V.
*
* In order to use the track outputs as gates to directly control non MIDI
* things, the red LEDs should be removed, keeping the 1K resistors. The
* outputs will be 0V off, +5V on, this will work with most modular synth
* things.
*
*/
#include <TimerOne.h> /* this library will provide the main clock */
#include <EEPROM.h> /* library to access Arduino internal EEPROM */
#include <Wire.h> /* 128x64 I2C OLED display related libraries */
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 /* OLED display width, in pixels */
#define SCREEN_HEIGHT 64 /* OLED display height, in pixels */

/* SSD1306 display connected to I2C (SDA, SCL pins) */
#define OLED_RESET -1 /* Reset pin # (or -1 if sharing Arduino reset pin) */
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#include "EncoderTool.h" /* include EncoderTool library */
using namespace EncoderTool;
PolledEncoder knobX, knobY; /* two rotary encoders */

const byte trackPins[8]={A2, A1, A0, 12, 11, 10, 9, 8}; /* tracks output pins */
const byte metronPin = A3; /* metronome pin, always pulsing at selected BPM */
const byte beatOnePin = 13; /* beat one pin, turns on only at the first beat of a pattern */
byte swAState = 0; /* swA switch state (012) from X encoder */
byte lastswAState = 0; /* swA switch last state */
byte swBState = 0; /* swB switch state (0123) from Y encoder */
byte lastswBState = 0; /* swB switch last state */
byte metr = 3; /* number of beats per pattern */
byte beat = 0; /* current beat */
byte oldBeat = 0; /* previous beat */
bool clockState = LOW; /* clock pulse state, low or high */
volatile uint32_t clockCount = 0; /* clock counter, increases when clockState is high */
uint32_t beatr = 0; /* play beat counter related things */
uint32_t metron = 0; /* metronome counter */
int trkSlot = 0, trkSlotOld = 0; /* track slots (screen x axis) */
int stpSlot = 0, stpSlotOld = 0; /* tick (step) slots (screen y axis) */
int preset = 0, oldPreset = 0; /* preset number */
uint16_t BPM = 120; /* tempo, Beats Per Minute */
const byte ticks = 12; /* ticks per beat */
const byte meter = 12; /* max. beats per pattern */
byte pattern[meter][ticks]={ /* pattern array */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* 12 ticks each one of the 12 beats */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* 8 tracks in each byte (8 bits) */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* this way we reduce memory usage, */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* representing the whole pattern */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* with 144 bytes */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
const byte prstSize = sizeof(pattern);
const byte nn[8]={35, 38, 42, 46, 45, 50, 64, 76}; /* GM drum notes */

/* The grid is drawn once, during setup() */
void drawGrid() /* the matrix grid */
{
for(int i = 0; i < 13; i++) /* from 0 to 12, draw 13 horizontal lines */
{
/* drawLine( x0, y0, x1, y1, color); */
oled.drawLine( 32, i*5, 97, i*5, WHITE); /* horizontal lines */
}
for(int i = 0; i < 9; i++) /* from 0 to 8, draw 9 vertical lines */
{
/* drawLine( x0, y0, x1, y1, color); */
oled.drawLine((i*8)+33, 0, (i*8)+33, 60, WHITE); /* vertical lines */
}
oled.setTextColor(WHITE, BLACK); /* white text over black background */
oled.setTextSize(1); /* font size 1 */
for(int i = 0; i < 12; i++)
{
oled.setCursor(i%2==0 ? 0 : 6, i*5); /* even numbers after a space */
oled.print(i+1, HEX); /* print row number in hexadecimal 1 - C */
}
oled.setCursor(105, 1); /* top right screen position */
oled.print(BPM, DEC); /* print the BPM value */
oled.setCursor(23, 1); /* cursor position */
oled.print(beat+1, DEC); /* print the beat value */
oled.setCursor(23, 28); /* center left screen position */
oled.print(metr+1, DEC); /* print the metr value */
oled.setCursor(20, 54); /* bottom left screen position */
oled.print(preset, DEC); /* print preset value */
} /* end of drawGrid() */

unrelatedactivities
Автор

Подскажите, это как контроллер для барабанов, или самостоятельная драм машина?
Tell me, is this like a controller for drums, or an independent drum machine?

abaddon_the_despoile
Автор

Code Part 03 :
/* loop() */
void loop(){
knobX.tick(); /* polled encoder -> call tick() as often as possible */
knobX.setLimits(-1, 1); /* limit encoder counter range to -1 and +1 */
knobY.tick(); /* polled encoder -> call tick() as often as possible */
knobY.setLimits(-1, 1); /* limit encoder counter range to -1 and +1 */

/* encoder X */
int newX; /* encoder variable for new readings */
if(knobX.valueChanged()) /* do we have a new encoder value? */
{
newX = knobX.getValue(); /* get its value and store in newX */
knobX.setValue(0); /* zeroes the encoder counter */
if(swAState != 2) /* add newX to trkslot and constrain its range to 0 - 7 */
{
trkSlot = constrain(trkSlot+newX, 0, 7);
}
else if(swAState == 2) /* if swAState 2, use newX to select beat */
{
beat = constrain(beat+newX, 0, metr); /* limit beat range to 0-metr */
/* x0, y0, w, h, color */
oled.fillRect(18, 1, 10, 7, BLACK); /* erase this screen area */
/* if greater than 8, cursor at x18y1, if not, cursor at x23y1 top left */
beat>8 ? oled.setCursor(18, 1) : oled.setCursor(23, 1); /* cursor position */
oled.setTextColor(WHITE, BLACK); /* white text over black background */
oled.setTextSize(1); /* font size 1 */
oled.print(beat+1, DEC); /* print the beat value */
oled.display();
}
}
/* encoder Y */
int newY; /* encoder variables for new readings */
if (knobY.valueChanged()) /* do we have a new encoder value? */
{
newY = knobY.getValue(); /* get its value and store in newY */
knobY.setValue(0); /* reset the encoder counter */
if(swBState == 0 && swAState != 2) /* if swBState is 0 and swAState is not 2, */
{ /* use newY to inc/dec stpSlot */
stpSlot = constrain(stpSlot+newY, 0, 11); /* limit stpSlot range to 0-11 */
}
else if(swBState == 1) /* if swBState 1, use newY to set tempo */
{
BPM = constrain(BPM+newY, 20, 300); /* limit tempo range to 20 - 300 BPM */
oled.fillRect(105, 1, 110, 7, BLACK); /* erase this screen area */
/* if BPM greater than 99, cursor at x105y1, if not, cursor at x111y1 top right */
BPM>99 ? oled.setCursor(105, 1) : oled.setCursor(111, 1);/* screen position */
oled.setTextColor(WHITE, BLACK); /* white text over black background */
oled.setTextSize(1); /* font size 1 */
oled.print(BPM, DEC); /* print the BPM value */
oled.display();
}
else if(swBState == 3) /* if swBState 3, use newY to select a preset */
{
preset = constrain(preset+newY, 0, 4); /* limit preset range to 0 - 4 */
oled.fillRect(20, 54, 5, 7, BLACK); /* erase this screen area */
oled.setCursor(20, 54); /* cursor position */
oled.setTextColor(WHITE, BLACK); /* white text over black background */
oled.setTextSize(1); /* font size 1 */
oled.print(preset, DEC); /* print the preset number */
oled.display();
}
if(swAState == 2 && swBState == 0) /* if swAState 2 and swBState 0 use */
{ /* newY to set meter */
metr = constrain(metr+newY, 0, 11); /* limit meter range to 0 - 11 */
oled.fillRect(18, 28, 10, 7, BLACK); /* erase this screen area */
/* if greater than 8, cursor at x18y28, if not, cursor at x23y28 center left */
metr>8 ? oled.setCursor(18, 28) : oled.setCursor(23, 28); /* cursor position */
oled.setTextColor(WHITE, BLACK); /* white text over black background */
oled.setTextSize(1); /* font size 1 */
oled.print(metr+1, DEC); /* print the meter + 1 value */
oled.display();
}
}

/* switches */
if(knobX.buttonChanged()) /* listen to knobX switch */
{
knobX.getButton() == LOW ? swAState++ : 0; /* if pressed, increase swAState variable value */
if(swAState % 3 == 0) swAState = 0; /* limit swAState value to 0 - 2 */
if(swAState == 0) oled.drawChar( 110, 48, 'C', WHITE, BLACK, 2); /* Cursor (edit) */
if(swAState == 1) oled.drawChar( 110, 48, 'W', WHITE, BLACK, 2); /* Write (edit) */
if(swAState == 2) oled.drawChar( 110, 48, 'B', WHITE, BLACK, 2); /* Beat (edit) */
oled.display();
}
if(knobY.buttonChanged()) /* listen to knobY switch */
{
knobY.getButton() == LOW ? swBState++ : 0; /* if pressed, increase swBState variable value */
if(swBState % 4 == 0) swBState = 0; /* limit swBState value to 0 - 3 */
if(swBState == 0) oled.drawChar( 110, 24, 'E', WHITE, BLACK, 2); /* Edit */
if(swBState == 1) oled.drawChar( 110, 24, 'T', WHITE, BLACK, 2); /* Tempo */
if(swBState == 2) oled.drawChar( 110, 24, 'P', WHITE, BLACK, 2); /* Play */
if(swBState == 3) /* this always comes after Play, use it to also reset it */
{
oled.drawChar( 110, 24, 'L', WHITE, BLACK, 2); /* Load */
play(0, 0, 0, 1); /* call function play() with reset */
for(byte i=0; i<8; i++)
{
digitalWrite(trackPins[i], LOW); /* set all tracks output pins off */
}
}
oled.display();
}
if(preset != oldPreset) /* if preset changed */
{
oldPreset = preset; /* update oldPreset */
presetRead(preset*prstSize); /* call function to load presets from eeprom */
/* argument is eeprom address, so multiply by the size of each preset (144) */
}

if(trkSlot != trkSlotOld || stpSlot != stpSlotOld) /* if coordinates have changed */
{ /* call function edit() to draw the */
edit(stpSlot, trkSlot, swAState, beat); /* cursor and write/erase slots */
trkSlotOld = trkSlot; /* update old coordinates */
stpSlotOld = stpSlot;
}

/* deal with time */
/* Timer1 period unit is microseconds, BPM is frequency in minutes, we need 24 clock
* pulses for each beat in order to get a rest after each tick (50% duty cycle), the
* clockCounter advances at each pulse high. So we need to divide 60 million µs by
* BPM*48 */
/ (BPM*48)); /* set period to get BPM, close enough */
metron = clockCount%24; /* metron counts from 0 to 23 */
uint32_t index = metron * 0.5; /* index for the 12 ticks in each beat */
beatr = (clockCount/24) % (metr+1); /* limit the beat counter to meter */
/* turn beatOnepin on if beatr and metron are zero, this is the first beat of a pattern: */
digitalWrite(beatOnePin, !beatr&&!metron?1:0);
bool mtrState = metron==0 ? 1 : 0;/* set the metronome state to true at the start of each beat */
digitalWrite(metronPin, mtrState); /* flash a LED each beat */
if(swBState == 2) /* if set to play */
{
play(metron, index, beatr, 0); /* call function play() */
}
} /* end of loop() */

unrelatedactivities
Автор

Code Part 04 :
/* read a beat from pattern[][] array and play it */
void play(uint32_t tick, uint32_t indx, uint32_t beatn, bool rst)
{
if(rst) /* if reset is true, zero beatr and return */
{
beatr = 0; /* *** this may have no effect, remember to check */
return;
}
byte rest1 = int((tick % 2)*255); /* I think we can call this an alternating rest mask */
byte data1 = pattern[beatn][indx];/* store tracks byte from pattern array in data1 variable */
for (byte x=0; x<8; x++) /* create a loop for the 8 tracks (rows) */
{
byte play = data1 & (1<<x); /* read data1 (hits), one bit each time */
byte rest = rest1 & (1<<x); /* read rest1 (rests), one bit each time */
if(play && !rest) /* if playing and not rest (boolean)... */
{
digitalWrite(trackPins[x], HIGH); /* correspondent output pin on */
Serial.write(153); /* note on channel 10 */
Serial.write(nn[x]); /* note number */
Serial.write(127); /* velocity 127 */
}
else if(play & rest) /* if playing and there a rest (bitwise)... */
{
digitalWrite(trackPins[x], LOW); /* correspondent output pin off */
Serial.write(153); /* note on channel 10 */
Serial.write(nn[x]); /* note number */
Serial.write(0); /* velocity 0 (noteOff) */
}
}
}

/* deal with cursor things and create/edit pattern *
* arguments y and x are grid coordinates and, together with beat, indexes for
* data in the array pattern[12][12]; state is the on-off state of the slot;
* metr is the pattern meter (beats per measure). */
void edit(byte y, byte x, byte state, byte beat)
{
if(beat != oldBeat) /* if variable beat has changed, we need to erase all grid slots, */
{ /* then load the current beat grid slots states */
oldBeat = beat; /* update variable oldBeat value */
for(byte b=0;b<12;b++) /* create a loop for the 12 subdivisions (ticks) of a beat */
{
for(byte a=0;a<8;a++) /* create a loop for the 8 tracks (rows) */
{
oled.fillRect(a*8+34, b*5+1, 7, 4, BLACK); /* erase all screen grid slots */
byte dataw = pattern[beat][b]; /* read the tracks byte (row) at tick b */
byte rstate = dataw & (1<<a); /* check bit (track) state and, */
/* if rstate is on (bit is 1), draw a white rectangle in the current grid slot, */
/* if rstate is off (bit is 0), draw a black rectangle in the current grid slot: */
oled.fillRect(a*8+35, b*5+2, 5, 2, rstate ? WHITE : BLACK);
}
}
}
/* now edit current beat rhythm figures, moving the cursor on the screen grid: */
for(byte b=0;b<12;b++) /* create a loop for the 12 subdivisions (ticks) */
{ /* of a beat (columns) */
for(byte a=0;a<8;a++) /* create a loop for the 8 tracks (rows) */
{ /* draw a hollow white rectangle (cursor) at current xy selected grid slot: */
oled.drawRect(a*8+34, b*5+1, 7, 4, (a==x) && (b==y) ? WHITE : BLACK);
}
}
/* and store things in the pattern[][] array: */
byte dataw = pattern[beat][y]; /* read selected tick at current beat */
/* if state (encoder X switch swAState) is non zero, set bit high, else low: */
pattern[beat][y] = state ? (dataw |= (1<<x)) : (dataw &= ~(1<<x));
/* and draw a rectangle in the current grid slot, white if state on, black oherwise: */
oled.fillRect(x*8+35, y*5+2, 5, 2, state ? WHITE : BLACK);
oled.display();
} /* end of edit() */

/* load a preset */
void presetRead(int addr) /* 4 presets were written to eeproom, here we read and load */
{ /* them to the pattern[][] array */
for(byte i = 0; i < prstSize; i++) /* for each byte of a preset */
{
byte j = i/12; /* 12 beats */
byte k = i%12; /* 12 ticks in each beat */
byte value = EEPROM.read(addr); /* read one byte at address addr and store it on value */
pattern[j][k]=value; /* write value to the pattern array at index j k */
addr = addr + 1; /* advance to next eeprom address */
}
delay(100); /* wait some time then update screen with the first beat of the preset pattern */
for(byte b=0;b<12;b++) /* create a loop for the 12 subdivisions (ticks) */
{ /* of a beat (columns) */
for(byte a=0;a<8;a++) /* create a loop for the 8 tracks (rows) */
{
oled.fillRect(a*8+34, b*5+1, 7, 4, BLACK); /* erase all screen grid slots */
byte dataw = pattern[0][b]; /* read the tracks byte (row) at tick b */
byte rstate = dataw & (1<<a); /* check bit (track) state and, */
/* if rstate is on (bit is 1), draw a white rectangle in the current grid slot, */
/* if rstate is off (bit is 0), draw a black rectangle in the current grid slot: */
oled.fillRect(a*8+35, b*5+2, 5, 2, rstate ? WHITE : BLACK);
}
oled.display();
}
} /* end of presetRead() */

enjoy, if you will.

unrelatedactivities
Автор

Нужна помощь почему дисплей 128x32 работает, а 128x64 нет ?

АлександрЛарин-ъх
Автор

Code Part 02 :
void mainClock(void) /* called by TimerOne */
{
if (clockState == LOW) /* create the clock and count the high states */
{
clockState = HIGH;
clockCount = clockCount + 1;
}
else
{
clockState = LOW;
}
} /* end of drawGrid() */

/* setup() */
void setup()
{
// Timer1.initialize(10417); /* initialize Timer1 with period 10417 */
/* initialize Timer1 with period 10417 */
/* call function mainClock every interrupt */

Serial.begin(57600); /* initialize serial for OLED debug */
/* SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally */
if(!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) /* oled I2C address 0x3C */
{ /* if oled failed to iitialize, */
Serial.println(F("SSD1306 allocation failed")); /* print a warn */
for(;;); /* Don't proceed, loop forever */
}
Serial.end(); /* end serial for OLED debug */
delay(200);
Serial.begin(31250); /* start serial for MIDI with 31250 baud rate */

oled.clearDisplay(); /* Clear the buffer */
oled.setTextSize(2); /* 2X-scale text */
oled.setTextColor(WHITE); /* Draw white text */
oled.setCursor(0, 0); /* Start at top-left corner */
/* Print some text to OLED display */
oled.display();
delay(100);
oled.println(F("RHYTHMIC"));
oled.display();
delay(100);
oled.println(F("PATTERNS"));
oled.display();
delay(100);
oled.println(F("SEQUENCER"));
/* Show the display buffer on the screen. You MUST call display()
after drawing commands to make them visible on screen */
oled.display();
delay(300); /* wait a little */
oled.clearDisplay(); /* then clear the display buffer */

for(byte i=0; i<8; i++)
{
pinMode(trackPins[i], OUTPUT); /* track pins as output */
digitalWrite(trackPins[i], LOW); /* all off */
}
pinMode(metronPin, OUTPUT); /* metronome pin as output */
digitalWrite(metronPin, LOW); /* turn LED off */
pinMode(beatOnePin, OUTPUT); /* first beat pin as output */
digitalWrite(beatOnePin, LOW); /* turn LED off */

/* Count Mode : Default (quarter, 1 Detent / Signal Period )
* (A, B, switch) connected to Arduino pins: */
knobX.begin( 5, 3, 7); /* initialize rotary encoders on pins 2-7 */
knobY.begin( 4, 2, 6);
drawGrid(); /* call the function that draws the 8x8 matrix grid */
oled.display(); /* and display it, will remain the same all the time */
} /* end of setup() */

unrelatedactivities
Автор

Hallo. Die Hardware ist hoffentlich korrekt gesteckt. Aber bei dem Code bekomme ich den einen Fehler nicht weg. Kann mir bitte jemand helfen, vieleicht ganz simpel, aber ich verzweifel. Vielen Dank
Fehlermeldung, bei Überprüfen:

mit fatal error: TimerOne.h: No such file or directory
#include <TimerOne.h> /* this library will provide the main clock */

compilation terminated.
exit status 1

Compilation error: TimerOne.h: No such file or directory

SvenJa-qx