Remembering a previous value?
i'm having little problem , i'm hoping can help!
what i'm trying create electric melodeon (like accordion). need take pressure value between set of bellows (which have done) , compare atmospheric pressure value (which have done).
then want create midi note depending on pressure value. essentially, if button being pressed, want 1 note if pressure value lower last pressure value, , different note if it's higher.
i'm having trouble getting arduino remember previous pressure value. there technique achieve this?
here's code [there bits of code key matrix, ignore them
]:
what i'm trying create electric melodeon (like accordion). need take pressure value between set of bellows (which have done) , compare atmospheric pressure value (which have done).
then want create midi note depending on pressure value. essentially, if button being pressed, want 1 note if pressure value lower last pressure value, , different note if it's higher.
i'm having trouble getting arduino remember previous pressure value. there technique achieve this?
here's code [there bits of code key matrix, ignore them
]:code: [select]
int analogvalue1 = 0; // value read pot
int differencebob = 0;
int oldbob = 0;
int bob = 0;
void setup() {
serial.begin(31250); // opens serial port, sets data rate 9600 bps
pinmode(1, output); //
pinmode(2, output); //
pinmode(3, output); //
pinmode(4, output); //
pinmode(5, output); //
pinmode(6, output); //
pinmode(7, input); //
pinmode(8, input); //
pinmode(9, input); //
pinmode(10, input); //
pinmode(11, input); //
pinmode(12, input); //
}
void loop() {
bob = analogread(a0) / 6;
oldbob = bob;
delay (10);
digitalwrite(2, high);
digitalwrite(3, low);
digitalwrite(4, low);
digitalwrite(5, low);
digitalwrite(6, low);
delay(5);
if (bob < oldbob); {
if (digitalread(7) == high) {
sendmidi (0x90, 40, bob);
}
if (digitalread(7) == low) {
sendmidi (0x80, 0x18, bob);
}}
if (bob > oldbob); {
if (digitalread(7) == high) {
sendmidi (0x90, 45, bob);
}
if (digitalread(7) == low) {
sendmidi (0x80, 0x18, bob);
}}
}
void sendmidi (int cmd, int value, int vel) {
serial.write (cmd);
serial.write (value);
serial.write (vel);
}
quote
i'm having trouble getting arduino remember previous pressure value. there technique achieve this?
store in global or static variable called "previouspressurevalue"
Arduino Forum > Using Arduino > Programming Questions > Remembering a previous value?
arduino
Comments
Post a Comment