I've tried to integrate if + else commands, but it doesn't work. I'm a super amateur, so if anyone has any tips having done this before, I'd be very grateful.
I'm not familiar with the particular sensor you are using, or with VMUSIC2, but my general approach would be something like:
Set value to sensor reading.
Convert value to something acceptable by VMUSIC2 (e.g. scaling, etc)
Send value to VMUSIC2 volume command (presuming such a thing exists) via serial
Thanks for your help! It turns out that I managed to get the whole thing to work today, here's the code, below.
best,
Miranda
int buttonPin = 2; // pushbutton
int val = 0; // variable for reading the pin statusint
int ledPin = 13; // choose the pin for the LED
boolean triggered = false; //
void setup()
{
Serial.begin(9600);
pinMode(buttonPin, INPUT); // button is your input
pinMode(ledPin, OUTPUT); // declare LED as output
}
void loop () {
val = digitalRead(buttonPin); // read input value
if (val == HIGH && !triggered) // if button's pressed
{
triggered = true;
digitalWrite(ledPin, HIGH); // LED on
Serial.print("V3A"); // play all files
Serial.print(13,BYTE);
}
if (val == LOW && triggered)
{
triggered = false;
digitalWrite(ledPin, LOW); // LED off
Serial.print("VST"); //stop playing
Serial.print(13,BYTE);
}