-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toggling/scrolling through a string or character keymap using YOUR OWN buttons/sensors #6
Comments
Looking at a similar problem, trying to navigate through strings on an old screen with a rollerball/joystick which is basically either an up or down movement. |
Update: Yesterday Scott reviewed and added code to my sketch, to address the functionality requirement I mentioned in the above post. Preface: At the bottom of the attached code is the crux of the process that I have discussed above (and that Scott added). `#include <AnalogSmooth.h> #include <CapacitiveSensor.h> const int stringNumber = 10; const String keyMap[stringNumber] = {"0", "this is an automated message ", "goodbye ", "call you later ", "see you later ", /* CapacitiveSensor cs_12_10 = CapacitiveSensor(12, 10); // 1 megohm resistor between pins 12 & 10, pin 10 is sensor pin, add wire, foil AnalogSmooth as = AnalogSmooth(); boolean fingerReleased = true; boolean stageOneLeft = false; // unsigned long startTime; //the overall time coun int counter = 0; //________________________ const long longPressTime = 1000; //if sensor 1 or 3 is held for longer than 1000ms, //__________________________________ void setup() // cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example pinMode (ledPin1, OUTPUT); cs_12_10.set_CS_AutocaL_Millis (30); //sensor calibration window Serial.begin(9600); void loop() //startTime = millis(); long total1 = cs_12_10.capacitiveSensor(1); float analogSmooth1 = total1; //Serial.print(millis() - start); // check on performance in milliseconds /* //delay(100); // arbitrary delay to limit data to serial port if ((total1 > 5) && (total3 < 7) && (stageOneLeft == false)) { if ((total1 < 5) && (total2 > 4 ) && (total3 < 8) && (stageOneRight == true)) { } if ((total3 > 6 ) && (total1 < 5) && (stageTwoRight == true)) {
} if ((total3 > 7 ) && (total1 < 6) && (stageOneRight == false)) { if ((total1 < 5) && (total2 > 4 ) && (total3 < 8) && (stageOneLeft == true)) { if ((total1 > 6 ) && (total3 < 7) && (stageTwoLeft == true)) {
}
} void displayString(int index) { ` |
So, I've got an array of 2-3 capacitive touch sensors which can determine whether a user is swiping left or right (or similarly, up and down).
Thus far, I have my own code which reads the capacitive sensors, determines the direction of the swipe and either adds or subtracts (a value) depending on the swipe direction. This value is a whole number, from 0 to 30 (it could be from 0-10, or 0-100 - the exact range is not a concern) and it is printed on the serial monitor when it is changed. This system is effectively a number counter.
For each value or counter number in this 0-30 range, there is a corresponding string or message - such as "see you soon", or "how are you?" that is located within the const String keyMap.
Is this starting to make sense?
My question is; how should the program acknowledge a particular current counter value and similarly 'tie' this to one of the keyMap strings?
In essence, I'd like to be able to print the string on the serial monitor.
Later on, I'd like to be able to display these strings on an OLED screen.
I will update this and post the functioning code once I have this solved. Stay tuned.
The text was updated successfully, but these errors were encountered: