Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of slider_diatonic_v1 by
Revision 4:de991c90af6a, committed 2015-02-23
- Comitter:
- destradafilm
- Date:
- Mon Feb 23 04:49:39 2015 +0000
- Parent:
- 3:f68e9cdfaf2d
- Commit message:
- slider_diatonic_changing Octaves
Changed in this revision
slider_diatonic_v1.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/slider_diatonic_v1.cpp Wed Feb 18 15:27:17 2015 +0000 +++ b/slider_diatonic_v1.cpp Mon Feb 23 04:49:39 2015 +0000 @@ -26,10 +26,14 @@ Serial pc(USBTX, USBRX); float diatonicScale[NUMTONES] = {246.94, 261.63,293.66,329.63,349.23,392.00,440.00,493.88,523.25,587.33}; +float diatonicScale2[NUMTONES] ={493.88, 523.25,587.33,659.25,698.46,783.99,880.00,987.77,1046.50,1174.66}; SLCD slcd; //define LCD display TSISensor tsiScaling; // Capacitive sensor/slider +// changes +DigitalIn RtButton(PTC3); // make RIGHT button interrrupt +int RtbuttonState; // switch changes when RtButton is pressed PwmOut led(LED_RED); DigitalOut outPin(PTC9); //J1-16 @@ -58,7 +62,11 @@ */ scaleIndex = (int)(NUMTONES * scaling); if (scaleIndex != oldScaleIndex) { + if(RtbuttonState == false){ toneFreq = diatonicScale[scaleIndex]; + } else { + toneFreq = diatonicScale2[scaleIndex]; + } tonePeriod = 1.0/toneFreq; soundOut.period(tonePeriod); // adjusting period soundOut.write(TONEON); // there is a setup time for both period and DF @@ -100,6 +108,9 @@ dataTimer.reset(); while (true) { + + RtbuttonState = RtButton; // button is pulled up so false is when button is pushed it's inverted to avoid confusion downstream + if (dataTimer.read_ms() > DATATIME){ // check to see if enough time has passed // to read the touch pad tempValue = tsiScaling.readPercentage();