The Code#define fsr 0
#define fsr2 1
// Middle C (MIDI note value 60) is the lowest note we'll play:
#define middleC 60
// Variables:
int AnalogValue = 0;
int AnalogValue2 = 0; // value from the analog input
int lastNotePlayed = 0; // note turned on when you press the switch
int note=0;
void setup()
{
// set the states of the I/O pins:
pinMode(fsr, INPUT);
pinMode(fsr2, INPUT);
// Set MIDI baud rate:
Serial.begin(31250);
}
void loop()
void noteOn(char cmd, char data1, char data2)
{
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}
#define fsr2 1
// Middle C (MIDI note value 60) is the lowest note we'll play:
#define middleC 60
// Variables:
int AnalogValue = 0;
int AnalogValue2 = 0; // value from the analog input
int lastNotePlayed = 0; // note turned on when you press the switch
int note=0;
void setup()
{
// set the states of the I/O pins:
pinMode(fsr, INPUT);
pinMode(fsr2, INPUT);
// Set MIDI baud rate:
Serial.begin(31250);
}
void loop()
{
AnalogValue = analogRead(0);
AnalogValue2 = analogRead(1);
//Serial.println(AnalogValue);
if (AnalogValue >100)
else if (AnalogValue2 >100)
}
AnalogValue = analogRead(0);
AnalogValue2 = analogRead(1);
//Serial.println(AnalogValue);
if (AnalogValue >100)
{
note = 60;
noteOn(0x90, note, 0x40);
// save the note we played, so we can turn it off:
lastNotePlayed = note;
}
note = 60;
noteOn(0x90, note, 0x40);
// save the note we played, so we can turn it off:
lastNotePlayed = note;
}
else if (AnalogValue2 >100)
{
note = 70;
noteOn(0x90, note, 0x40);
// save the note we played, so we can turn it off:
lastNotePlayed = note;
}
note = 70;
noteOn(0x90, note, 0x40);
// save the note we played, so we can turn it off:
lastNotePlayed = note;
}
}
void noteOn(char cmd, char data1, char data2)
{
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}
0 comments:
Post a Comment