Robertsonics Wave Trigger with Joystick Module

Hello, I'm working on a project using the wave trigger, with a joystick module, and an Arduino nano for ADC. I'm wondering if anybody else is doing anything similar. Also, more specifically, if anybody has any ideas on how to write IDE code to play different wave files with each successive push of the joystick in a particular direction. Right now I have it programmed to play 4 chords (one for each direction of the joystick), but it would be cool to play the chord with the first push, and higher octave melody notes with each successive push. A push in a different direction would reset the sequence to play the chord once pushed in the original direction. Here's the code I'm using now:

void setup() { int DATA; // put xour setup code here, to run once: pinMode(1,OUTPUT); pinMode(2,OUTPUT); pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); pinMode(7,OUTPUT); pinMode(8,OUTPUT); pinMode(9,OUTPUT); pinMode(10,OUTPUT); pinMode(11,OUTPUT); pinMode(12,OUTPUT); digitalWrite(1,HIGH); digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH); digitalWrite(9,HIGH); digitalWrite(10,HIGH); digitalWrite(11,HIGH); digitalWrite(12,HIGH); Serial.begin(9600); } void loop() { // read the input on analog pin 0: int yValue = analogRead(A1); int xValue = analogRead(A0); // print out the value xou read: Serial.println(xValue); delay(1); // delay in between reads for stabilitx if (xValue==0){ //output for DOWN digitalWrite(4,LOW); digitalWrite(5,HIGH); }else{ if (xValue==1023){ //OUTPUT FOR UP digitalWrite(5,LOW); digitalWrite(4,HIGH); }else{ digitalWrite(4,HIGH); digitalWrite(5,HIGH); } } if (yValue==0){ //output for DOWN digitalWrite(2,LOW); digitalWrite(3,HIGH); }else{ if (yValue==1023){ //OUTPUT FOR UP digitalWrite(3,LOW); digitalWrite(2,HIGH); }else{ digitalWrite(2,HIGH); digitalWrite(3,HIGH); } } }

Please read the how to use this forum sticky post it will tell you how to post code. In short use copy “for forum” in the IDE and paste it into the reply box.

delay(1);        // delay in between reads for stabilitx

Is just rubbish. Get rid of it. Some idiot who doesn’t understand things put it in a tutorial once and it has spread like the plague.

To count the number of pushes you have to detect when a push occurs rather than when a push is happening. Look at the state change example in the IDE under examples to see how it is done.

Work on this for one direction only at first and then extend it when you have that working.

Great, I'll try that, thanks!!