Skip to content
Snippets Groups Projects
Unverified Commit ccc4925e authored by Andreas Horn's avatar Andreas Horn
Browse files

adds 7th and 8th valve

parent 76d81a8f
No related branches found
No related tags found
No related merge requests found
......@@ -17,23 +17,25 @@
#define VALVE_3 7 // PE6 // 4mm
#define VALVE_4 8 // PB4 // 4mm
#define VALVE_5 9 // PB5 // 4mm
#define VALVE_6 3 // PD0 // 4mm
#define VALVE_7 2 // PD1 // 4mm
#define NUM_VALVES 6
#define NUM_VALVES 8
// array of currently active notes, index 0 is the oldest one
static int16_t notes[NUM_VALVES] = {-1, -1, -1, -1, -1, -1};
static int16_t notes[NUM_VALVES] = {-1, -1, -1, -1, -1, -1, -1, -1};
// array of the length of the tone period required to create the tone
static uint16_t periods[NUM_VALVES] = {0, 0, 0, 0, 0, 0};
static uint16_t periods[NUM_VALVES] = {0, 0, 0, 0, 0, 0, 0, 0};
// array of the current state of the valve pins (for tone periods)
static uint8_t states[NUM_VALVES] = {0, 0, 0, 0, 0, 0};
static uint8_t states[NUM_VALVES] = {0, 0, 0, 0, 0, 0, 0, 0};
// array for the period timer helpers
static uint64_t lastNoteMicros[NUM_VALVES] = {0, 0, 0, 0, 0, 0};
static uint64_t lastNoteMicros[NUM_VALVES] = {0, 0, 0, 0, 0, 0, 0, 0};
// array of the valve pin numbers
static const uint8_t valves[NUM_VALVES] = {VALVE_0, VALVE_1, VALVE_2, VALVE_3, VALVE_4, VALVE_5};
static const uint8_t valves[NUM_VALVES] = {VALVE_0, VALVE_1, VALVE_2, VALVE_3, VALVE_4, VALVE_5, VALVE_6, VALVE_7};
static float noteToMidi[128];
......@@ -895,24 +897,30 @@ void loop() {
//digitalWrite(valves[i], states[i]);
switch (i) {
case 0: // PD4
case 0: // PD4 // 6mm
PORTD ^= B00010000;
break;
case 1: // PC6
case 1: // PC6 // 6mm
PORTC ^= B01000000;
break;
case 2: // PD7
case 2: // PD7 // 6mm
PORTD ^= B10000000;
break;
case 3: // PE6
case 3: // PE6 // 4mm
PORTE ^= B01000000;
break;
case 4: // PB4
case 4: // PB4 // 4mm
PORTB ^= B00010000;
break;
case 5: // PB5
case 5: // PB5 // 4mm
PORTB ^= B00100000;
break;
case 6: // PD0 // 4mm
PORTD ^= B00000001;
break;
case 7: // PD1 // 4mm
PORTD ^= B00000010;
break;
}
} else if (notes[i] == -1) { // be sure to end notes that should be ended
digitalWrite(valves[i], LOW);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment