Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add patterns, Unique note trigs

- Have D1 only trig out if the note is unique, e.g. not same as last one.
  • Loading branch information...
commit fe2532fe169a190b0b8ce74bd2fadeb111e5ba59 1 parent 236b50e
@Magnus-G authored
Showing with 31 additions and 11 deletions.
  1. +31 −11 ScalePlayer/ScalePlayer/ScalePlayer.ino
View
42 ScalePlayer/ScalePlayer/ScalePlayer.ino
@@ -13,9 +13,11 @@ int digState[2] = {LOW, LOW}; // start with both set low
unsigned long digMilli[2] = {0, 0}; // a place to store millis()
int currentScaleValue = 0;
+int previousNote = 98;
-const int noOfPatterns = 3;
+const int noOfPatterns = 9; // plus one here if a pattern is added to "pattern"
+
const int patternLength = 9;
int patternValue;
int patternType;
@@ -23,7 +25,17 @@ int patternTypeUtility = 1023 / noOfPatterns;
int patternPlace = 0;
int pattern[noOfPatterns][patternLength] = {
{8,7,6,5,4,3,2,1,0},
- {0,1,2,3,4,5,6,7,8}
+ {0,1,2,3,4,5,6,7,8},
+
+ {0,1,0,2,0,3,0,4,3},
+
+ {0,2,3,2,3,5,3,5,2},
+ {0,1,2,3,8,7,6,5,4},
+ {0,8,1,7,2,6,3,5,4},
+ {0,1,8,7,2,3,6,5,4},
+
+ {0,0,0,1,2,4,3,8,7},
+ {0,0,0,0,0,1,1,2,2},
};
@@ -95,22 +107,24 @@ void setup()
void loop() {
- scale = (analogRead(2) / scaleUtility) -1;
- if (scale == -1) {scale = 0;}
+ scale = (analogRead(2) / scaleUtility) -1; if (scale == -1) {scale = 0;}
+
+ patternType = (analogRead(3) / patternTypeUtility) -1; if (patternType == -1) {patternType = 0;}
- patternType = (analogRead(3) / patternTypeUtility) -1;
- if (patternType == -1) {patternType = 0;}
- digitalWrite(digPin[0], clkState);
- digitalWrite(digPin[1], clkState);
+
if (clkState == HIGH) {
clkState = LOW;
+
+ digitalWrite(digPin[0], HIGH);
+ digitalWrite(digPin[0], LOW);
+
patternValue = pattern[patternType][patternPlace];
- Serial.print("patternValue: "); Serial.println(patternValue);
- Serial.print("patternPlace: "); Serial.println(patternPlace);
+// Serial.print("patternValue: "); Serial.println(patternValue);
+// Serial.print("patternPlace: "); Serial.println(patternPlace);
while (scales[scale][patternValue] == 99) {
patternPlace++;
@@ -124,6 +138,13 @@ void loop() {
int note = (((scales[scale][patternValue]) * 4) + (12 * 4));
dacOutput(note);
+
+ if (previousNote != note) {
+ digitalWrite(digPin[1], HIGH);
+ digitalWrite(digPin[1], LOW);
+ }
+
+ previousNote = note;
patternPlace++;
@@ -167,4 +188,3 @@ void dacOutput(long v)
tmpVal = tmpVal >> 1;
}
}
-
Please sign in to comment.
Something went wrong with that request. Please try again.