Components and supplies
Rotary potentiometer (generic)
Male-Header 36 Position 1 Row- Long (0.1")
Resistor 10k ohm
Slide Switch
Arduino UNO
Tools and machines
Soldering iron (generic)
Project description
Code
StepSequencer-ShieldOracolo.ino
c_cpp
This code allows to realize a step sequencer using an Arduino Uno board.
1/* 2 ++ 6 STEP SEQUENCER ++ 3 4 DESCRIPTION: 5 Reads values from 6 potentiometers to change the pitch of any step of the sequencer tone generator. 6 Change the pitch of each step with a potentiometer. 7 8 CIRCUIT: 9 Connect a speaker or piezo to pin number 13 and to ground; 10 Connect the first lead of a potentiometer to 5v and the last to ground, the one in the middle to Analog Input pin 0; 11 (Repeat for all the four potentiometers connecting the middle lead to Analog Input pins 0, 1, 2, 3, 4, 5); 12 Connect a switch from digital port 3 and ground, put a 220 Ohm Resistor between the digital port 3 and 5V; 13 14 For more information follow this link: http://www.artislab.it/it/step-sequencer/ 15 16 This example code is for educational purpose and it is in the public domain. 17 Author: Costantino Rizzuti 2016 18 Derived by a previous sketch made by Alessandro Contini & Paolo Cavagnolo 19 20*/ 21 22// Tones table definition 23#define NOTE_B0 31 24#define NOTE_C1 33 25#define NOTE_CS1 35 26#define NOTE_D1 37 27#define NOTE_DS1 39 28#define NOTE_E1 41 29#define NOTE_F1 44 30#define NOTE_FS1 46 31#define NOTE_G1 49 32#define NOTE_GS1 52 33#define NOTE_A1 55 34#define NOTE_AS1 58 35#define NOTE_B1 62 36#define NOTE_C2 65 37#define NOTE_CS2 69 38#define NOTE_D2 73 39#define NOTE_DS2 78 40#define NOTE_E2 82 41#define NOTE_F2 87 42#define NOTE_FS2 93 43#define NOTE_G2 98 44#define NOTE_GS2 104 45#define NOTE_A2 110 46#define NOTE_AS2 117 47#define NOTE_B2 123 48#define NOTE_C3 131 49#define NOTE_CS3 139 50#define NOTE_D3 147 51#define NOTE_DS3 156 52#define NOTE_E3 165 53#define NOTE_F3 175 54#define NOTE_FS3 185 55#define NOTE_G3 196 56#define NOTE_GS3 208 57#define NOTE_A3 220 58#define NOTE_AS3 233 59#define NOTE_B3 247 60#define NOTE_C4 262 61#define NOTE_CS4 277 62#define NOTE_D4 294 63#define NOTE_DS4 311 64#define NOTE_E4 330 65#define NOTE_F4 349 66#define NOTE_FS4 370 67#define NOTE_G4 392 68#define NOTE_GS4 415 69#define NOTE_A4 440 70#define NOTE_AS4 466 71#define NOTE_B4 494 72#define NOTE_C5 523 73#define NOTE_CS5 554 74#define NOTE_D5 587 75#define NOTE_DS5 622 76#define NOTE_E5 659 77#define NOTE_F5 698 78#define NOTE_FS5 740 79#define NOTE_G5 784 80#define NOTE_GS5 831 81#define NOTE_A5 880 82#define NOTE_AS5 932 83#define NOTE_B5 988 84#define NOTE_C6 1047 85#define NOTE_CS6 1109 86#define NOTE_D6 1175 87#define NOTE_DS6 1245 88#define NOTE_E6 1319 89#define NOTE_F6 1397 90#define NOTE_FS6 1480 91#define NOTE_G6 1568 92#define NOTE_GS6 1661 93#define NOTE_A6 1760 94#define NOTE_AS6 1865 95#define NOTE_B6 1976 96#define NOTE_C7 2093 97#define NOTE_CS7 2217 98#define NOTE_D7 2349 99#define NOTE_DS7 2489 100#define NOTE_E7 2637 101#define NOTE_F7 2794 102#define NOTE_FS7 2960 103#define NOTE_G7 3136 104#define NOTE_GS7 3322 105#define NOTE_A7 3520 106#define NOTE_AS7 3729 107#define NOTE_B7 3951 108#define NOTE_C8 4186 109#define NOTE_CS8 4435 110#define NOTE_D8 4699 111#define NOTE_DS8 4978 112 113 114// Declaration of tones used in the sequencer 115// Define here the note you want to play. 116// The first notes are mapped to the lowest position of the pots 117int pitch[] = { 118 NOTE_C3, 119 NOTE_GS3, 120 NOTE_CS3, 121 NOTE_AS3, 122 NOTE_A3, 123 NOTE_B3, 124 NOTE_F4, 125 NOTE_DS4, 126 NOTE_E4, 127 NOTE_G3, 128 NOTE_D4, 129 NOTE_FS4}; 130 131 132// Declaration of variables 133int speaker = 9; // Speaker output pin 134int k=0; // Variable to store the value of the loop 135int POT1 = A0; // POT1 pin 136int POT2 = A1; // POT2 pin 137int POT3 = A2; // POT3 pin 138int POT4 = A3; // POT4 pin 139int POT5 = A4; // POT5 pin 140int POT6 = A5; // POT6 pin 141int ReadPot1,ReadPot2,ReadPot3,ReadPot4,ReadPot5,ReadPot6; // Variable to store the value of the pots 142// Variables used to calculate tempo 143// set BPM 144int bpm=180; 145// set Subdivision 1=quarter note; 0.5 ->eight note, .... 146float subdivision=1; 147//Define here the sequence of durations 148//-> 1->quarter note; 0.5 ->eight note, .... 149float D[] = {1, 0.5, 0.5, 0.333, 0.333, 0.333}; //3/4 pattern 150//float D[] = {1, 0.5, 0.5, 1,0.5, 0.5}; //4/4 pattern 151// The lenght of the D array 152int NDuration=6; 153int DurCount=0; 154int value[] = {0, 0, 0, 0, 0, 0}; // value to define the discrete interval of tune using the pot 155int note[] = {0, 0, 0, 0, 0, 0}; 156int interval; 157 158void setup() { 159 pinMode(3, INPUT); 160 //Period computed according bpm and subdivision 161 interval = 60000/(subdivision*bpm); 162} 163 164 165void loop() { 166 if(digitalRead(3)==HIGH){ 167 for (k = 0; k <= 5; k++) { // Cycle on each pot 168 value[k] = map(analogRead(k), 0, 1023, 0, 2500); // Mapping the value of the Potentiometer to have a wider range of values 169 170 if ((value[k]>=0) && (value[k]<100)) // Discretization of the pot intervals - in order to assign the note 171 note[k] = 0; 172 if ((value[k]>=100) && (value[k]<300)) 173 note[k] = pitch[0]; 174 if ((value[k]>=300) && (value[k]<500)) 175 note[k] = pitch[1]; 176 if ((value[k]>=500) && (value[k]<700)) 177 note[k] = pitch[2]; 178 if ((value[k]>=700) && (value[k]<900)) 179 note[k] = pitch[3]; 180 if ((value[k]>=900) && (value[k]<1100)) 181 note[k] = pitch[4]; 182 if ((value[k]>=1100) && (value[k]<1300)) 183 note[k] = pitch[5]; 184 if ((value[k]>=1300) && (value[k]<1500)) 185 note[k] = pitch[6]; 186 if ((value[k]>=1500) && (value[k]<1700)) 187 note[k] = pitch[7]; 188 if ((value[k]>=1700) && (value[k]<=1900)) 189 note[k] = pitch[8]; 190 if ((value[k]>=1900) && (value[k]<=2100)) 191 note[k] = pitch[9]; 192 if ((value[k]>=2100) && (value[k]<=2300)) 193 note[k] = pitch[10]; 194 if ((value[k]>=2300) && (value[k]<=2500)) 195 note[k] = pitch[11]; 196 197 float Duration=D[DurCount]*interval; 198 tone(speaker, note[k], Duration); // Play the note 199 DurCount++; 200 if(DurCount>=NDuration)DurCount=0; 201 202 delay(Duration); 203 } 204 } 205} 206
StepSequencer-ShieldOracolo.ino
c_cpp
This code allows to realize a step sequencer using an Arduino Uno board.
1/* 2 ++ 6 STEP SEQUENCER ++ 3 4 DESCRIPTION: 5 Reads values 6 from 6 potentiometers to change the pitch of any step of the sequencer tone generator. 7 8 Change the pitch of each step with a potentiometer. 9 10 CIRCUIT: 11 12 Connect a speaker or piezo to pin number 13 and to ground; 13 Connect the first 14 lead of a potentiometer to 5v and the last to ground, the one in the middle to Analog 15 Input pin 0; 16 (Repeat for all the four potentiometers connecting the middle 17 lead to Analog Input pins 0, 1, 2, 3, 4, 5); 18 Connect a switch from digital 19 port 3 and ground, put a 220 Ohm Resistor between the digital port 3 and 5V; 20 21 22 For more information follow this link: http://www.artislab.it/it/step-sequencer/ 23 24 25 This example code is for educational purpose and it is in the public domain. 26 27 Author: Costantino Rizzuti 2016 28 Derived by a previous sketch made by Alessandro 29 Contini & Paolo Cavagnolo 30 31*/ 32 33// Tones table definition 34#define 35 NOTE_B0 31 36#define NOTE_C1 33 37#define NOTE_CS1 35 38#define NOTE_D1 37 39#define 40 NOTE_DS1 39 41#define NOTE_E1 41 42#define NOTE_F1 44 43#define NOTE_FS1 46 44#define 45 NOTE_G1 49 46#define NOTE_GS1 52 47#define NOTE_A1 55 48#define NOTE_AS1 58 49#define 50 NOTE_B1 62 51#define NOTE_C2 65 52#define NOTE_CS2 69 53#define NOTE_D2 73 54#define 55 NOTE_DS2 78 56#define NOTE_E2 82 57#define NOTE_F2 87 58#define NOTE_FS2 93 59#define 60 NOTE_G2 98 61#define NOTE_GS2 104 62#define NOTE_A2 110 63#define NOTE_AS2 64 117 65#define NOTE_B2 123 66#define NOTE_C3 131 67#define NOTE_CS3 139 68#define 69 NOTE_D3 147 70#define NOTE_DS3 156 71#define NOTE_E3 165 72#define NOTE_F3 73 175 74#define NOTE_FS3 185 75#define NOTE_G3 196 76#define NOTE_GS3 208 77#define 78 NOTE_A3 220 79#define NOTE_AS3 233 80#define NOTE_B3 247 81#define NOTE_C4 82 262 83#define NOTE_CS4 277 84#define NOTE_D4 294 85#define NOTE_DS4 311 86#define 87 NOTE_E4 330 88#define NOTE_F4 349 89#define NOTE_FS4 370 90#define NOTE_G4 91 392 92#define NOTE_GS4 415 93#define NOTE_A4 440 94#define NOTE_AS4 466 95#define 96 NOTE_B4 494 97#define NOTE_C5 523 98#define NOTE_CS5 554 99#define NOTE_D5 100 587 101#define NOTE_DS5 622 102#define NOTE_E5 659 103#define NOTE_F5 698 104#define 105 NOTE_FS5 740 106#define NOTE_G5 784 107#define NOTE_GS5 831 108#define NOTE_A5 109 880 110#define NOTE_AS5 932 111#define NOTE_B5 988 112#define NOTE_C6 1047 113#define 114 NOTE_CS6 1109 115#define NOTE_D6 1175 116#define NOTE_DS6 1245 117#define NOTE_E6 118 1319 119#define NOTE_F6 1397 120#define NOTE_FS6 1480 121#define NOTE_G6 1568 122#define 123 NOTE_GS6 1661 124#define NOTE_A6 1760 125#define NOTE_AS6 1865 126#define NOTE_B6 127 1976 128#define NOTE_C7 2093 129#define NOTE_CS7 2217 130#define NOTE_D7 2349 131#define 132 NOTE_DS7 2489 133#define NOTE_E7 2637 134#define NOTE_F7 2794 135#define NOTE_FS7 136 2960 137#define NOTE_G7 3136 138#define NOTE_GS7 3322 139#define NOTE_A7 3520 140#define 141 NOTE_AS7 3729 142#define NOTE_B7 3951 143#define NOTE_C8 4186 144#define NOTE_CS8 145 4435 146#define NOTE_D8 4699 147#define NOTE_DS8 4978 148 149 150// Declaration 151 of tones used in the sequencer 152// Define here the note you want to play. 153// 154 The first notes are mapped to the lowest position of the pots 155int pitch[] = { 156 157 NOTE_C3, 158 NOTE_GS3, 159 NOTE_CS3, 160 161 NOTE_AS3, 162 NOTE_A3, 163 NOTE_B3, 164 165 NOTE_F4, 166 NOTE_DS4, 167 NOTE_E4, 168 169 NOTE_G3, 170 NOTE_D4, 171 NOTE_FS4}; 172 173 174 175// Declaration of variables 176int 177 speaker = 9; // Speaker output pin 178int k=0; // 179 Variable to store the value of the loop 180int POT1 = A0; // 181 POT1 pin 182int POT2 = A1; // POT2 pin 183int POT3 184 = A2; // POT3 pin 185int POT4 = A3; // 186 POT4 pin 187int POT5 = A4; // POT5 pin 188int POT6 189 = A5; // POT6 pin 190int ReadPot1,ReadPot2,ReadPot3,ReadPot4,ReadPot5,ReadPot6; 191 // Variable to store the value of the pots 192// Variables 193 used to calculate tempo 194// set BPM 195int bpm=180; 196// set Subdivision 1=quarter 197 note; 0.5 ->eight note, .... 198float subdivision=1; 199//Define here the sequence 200 of durations 201//-> 1->quarter note; 0.5 ->eight note, .... 202float D[] = {1, 203 0.5, 0.5, 0.333, 0.333, 0.333}; //3/4 pattern 204//float D[] = {1, 0.5, 0.5, 1,0.5, 205 0.5}; //4/4 pattern 206// The lenght of the D array 207int NDuration=6; 208int 209 DurCount=0; 210int value[] = {0, 0, 0, 0, 0, 0}; 211 // value to define the discrete interval of tune using the pot 212int 213 note[] = {0, 0, 0, 0, 0, 0}; 214int interval; 215 216void setup() { 217 pinMode(3, 218 INPUT); 219 //Period computed according bpm and subdivision 220 interval = 221 60000/(subdivision*bpm); 222} 223 224 225void loop() { 226 if(digitalRead(3)==HIGH){ 227 228 for (k = 0; k <= 5; k++) { // Cycle on each 229 pot 230 value[k] = map(analogRead(k), 0, 1023, 0, 2500); // Mapping 231 the value of the Potentiometer to have a wider range of values 232 233 if 234 ((value[k]>=0) && (value[k]<100)) // Discretization of the pot 235 intervals - in order to assign the note 236 note[k] = 0; 237 if 238 ((value[k]>=100) && (value[k]<300)) 239 note[k] = pitch[0]; 240 if ((value[k]>=300) 241 && (value[k]<500)) 242 note[k] = pitch[1]; 243 if ((value[k]>=500) && 244 (value[k]<700)) 245 note[k] = pitch[2]; 246 if ((value[k]>=700) && (value[k]<900)) 247 248 note[k] = pitch[3]; 249 if ((value[k]>=900) && (value[k]<1100)) 250 251 note[k] = pitch[4]; 252 if ((value[k]>=1100) && (value[k]<1300)) 253 254 note[k] = pitch[5]; 255 if ((value[k]>=1300) && (value[k]<1500)) 256 257 note[k] = pitch[6]; 258 if ((value[k]>=1500) && (value[k]<1700)) 259 260 note[k] = pitch[7]; 261 if ((value[k]>=1700) && (value[k]<=1900)) 262 263 note[k] = pitch[8]; 264 if ((value[k]>=1900) && (value[k]<=2100)) 265 266 note[k] = pitch[9]; 267 if ((value[k]>=2100) && (value[k]<=2300)) 268 269 note[k] = pitch[10]; 270 if ((value[k]>=2300) && (value[k]<=2500)) 271 272 note[k] = pitch[11]; 273 274 float Duration=D[DurCount]*interval; 275 276 tone(speaker, note[k], Duration); // Play the note 277 DurCount++; 278 279 if(DurCount>=NDuration)DurCount=0; 280 281 delay(Duration); 282 283 } 284 } 285} 286
Downloadable files
StepSequencer Circuit
The circuit diagram for the step sequencer
StepSequencer Circuit
StepSequencer Circuit
The circuit diagram for the step sequencer
StepSequencer Circuit
StepSequencer Skematic
The circuit schematic for the step sequencer
StepSequencer Skematic
Comments
Only logged in users can leave comments