Four way scrolling, all easily done with one finger.
My first Arduino sketch attempt in the previous project log was awful, but a milestone for me. I really love the touch sensors now that I am more familiar with them. The Teensy 3.1 has twelve touch sensor pins, 9 on top, and 3 solder pads on the bottom of its PCB. (Unnecessary Teensy raving link... http://hackaday.io/project/1397-36-Touch-Sensor-Matrix ) The new touch sensor below that I have been developing is so much better that I have not been able to stop using it, even though it is not even close to my mouse. I like it so much better than any wheel I have tried. This will definitely be on the final Prototyping Mouse.
Layout from the middle of the picture below:
1. The center red insulated wire is not connected. It is used for tactile reference only.
2. Slow scroll up.
3. Touch both wires for medium scroll up. Can be done by rolling finger forward.
4. Fast scroll up.
5. A little extra space below for my lazy finger.
6 & 7. Slow, medium and fast down.
8. Left arrow key.
9. Right arrow key.
10. Future touch location for Ctlr Lock.
11. Future touch location for Shift Lock.
Ctrl Lock makes up and down zoom.
Shift Lock makes scroll up and down move a horizontal scroll bar left and right.
Low Vision Bonus:
The Ctrl lock feature, had an unexpected accessibility advantage as a magnifier for the visually impaired. Because it meets the requirement of no drivers it switched easily from Windows to Linux without being “Windows Magnifier” dependent.
Other ideas I am playing around with:
Ctrl Zero:
A touch location for normal zoom, in case I play around with zooming too much.
Scroll Speed:
The pictures above show the small black tactile switches I have been experimenting with. One was Ctrl Lock, which I plan to move to a touch location as mentioned above. Two others adjusted scroll speed, but after testing, I stayed on one set of lines per scroll: Slow = 1, Medium = 3, Fast = 5. So I am killing that idea.
Micro Move:
The four cross pattern tactile switches move the mouse pointer one pixel at a time. If you have a trembling hand, it is easy to get frustrated with photo and 3D software. This allows you to take your hand off, take a breath and fine tune, without having to release an object. This version may not make it to my final prototype. I need to upgrade this idea with a micro joystick or reluctantly integrating it into the trackball in the future.
Brass Tacks:
Right now I am still using bare copper wire bent into staple shapes. I am looking for a better non-oxidizing conductive material that might be better to touch. I might murder a laptop touch pad for fun or resort to stainless steel. For single buttons, old fashion thumb tacks seem visually appealing right now for some reason. This needs more research.
(Picture may seam unrealistic, but contains no blood and has not been photoshopped :)
Much Better Code:
The code is more refined and stable now. This sets the foundation for all of the other switches and final sketch. The sample below will be upgraded in later logs as things move along. (Indenting ruined below. Ask if you want a real copy.)
//Button setup:<br>#include <Bounce.h><br>const int b = 8; // Number of pushbuttons used<br>int buttonPin[b]={12, 11, 19, 20, 10, 9, 21, 22}; // Pushbutton pin numbers:<br>Bounce touchDelayUp = Bounce(buttonPin[0], 10); // 10 ms debounce<br>Bounce touchDelayDown = Bounce(buttonPin[1], 10);<br>Bounce ctrlHold = Bounce(buttonPin[2], 10);<br>Bounce microMoveAdj = Bounce(buttonPin[3], 10);<br>Bounce microMoveUp = Bounce(buttonPin[4], 10);<br>Bounce microMoveLeft = Bounce(buttonPin[5], 10);<br>Bounce microMoveRight = Bounce(buttonPin[6], 10);<br>Bounce microMoveDown = Bounce(buttonPin[7], 10);<br><br>boolean ctrlToggle = false;<br>int microMove = 1; // Amount of positions moved at one time<br><br>// Touch scrolling setup:<br>const int t = 6; // Number of touch sensors used<br>int touch[t]={1, 15, 17, 18, 0, 16};<br> // Touch pin numbers in order:<br> // Top, Up, Down, Bottom, Left, Right<br>int base[t];<br>int reading[t];<br>boolean touched = false;<br><br>// Touch sensor adjustments:<br>int sensitivity = 130;<br>int slow = 1; // Scroll speed...<br>int medium = 3;<br>int fast = 5;<br>int touchDelay = 100;<br>int Delay = 100;<br><br>int c; // Generic counter<br>int led = 13; // Blink conformation<br><br>void setup() { <br> Serial.begin(38400);<br> for (c=0; c<b; c++) {<br> pinMode(buttonPin[c], INPUT_PULLUP);<br> }<br> for (c=0; c<t; c++) {<br> base[c]=touchRead(touch[c]); // Baseline calibration<br> }<br> pinMode(led, OUTPUT);<br>}<br><br>void loop() {<br><br>// Pushbutton section:<br><br> // Micro move the position of the mouse pionter<br> if (microMoveUp.update()) {<br> if (microMoveUp.fallingEdge()) {<br> while (!microMoveUp.risingEdge()) {<br> Mouse.move(0, -microMove);<br> microMoveUp.update();<br> delay(255);<br> }<br> }<br> }<br> if (microMoveLeft.update()) {<br> if (microMoveLeft.fallingEdge()) {<br> while (!microMoveLeft.risingEdge()) {<br> Mouse.move(-microMove, 0);<br> microMoveLeft.update();<br> delay(255);<br> }<br> }<br> }<br> if (microMoveRight.update()) {<br> if (microMoveRight.fallingEdge()) {<br> while (!microMoveRight.risingEdge()) {<br> Mouse.move(microMove, 0);<br> microMoveRight.update();<br> delay(255);<br> }<br> }<br> }<br> if (microMoveDown.update()) {<br> if (microMoveDown.fallingEdge()) {<br> while (!microMoveDown.risingEdge()) {<br> Mouse.move(0, microMove);<br> microMoveDown.update();<br> delay(255);<br> }<br> }<br> }<br> // Amount mouse pointer moves at one time<br> if (microMoveAdj.update()) {<br> if (microMoveAdj.fallingEdge()) {<br> if (microMove < 15) {<br> microMove = microMove + 3;<br> } else {<br> microMove = 1;<br> }<br> delay(150);<br> for (c=0; c < microMove; c=c+3) {<br> digitalWrite(led, HIGH);<br> delay(150);<br> digitalWrite(led, LOW);<br> delay(150);<br> }<br> }<br> }<br> // CTRL toggle: Flase= no modifier, True= CTRL always held down<br> if (ctrlHold.update()) {<br> if (ctrlHold.fallingEdge()) {<br> if (!ctrlToggle) {<br> Keyboard.set_modifier(MODIFIERKEY_CTRL);<br> Keyboard.send_now();<br> ctrlToggle = true;<br> } else {<br> Keyboard.set_modifier(0);<br> Keyboard.send_now();<br> ctrlToggle = false;<br> }<br> }<br> }<br><br>// Touch scrolling sections:<br><br> // Touch scroll speed buttons:<br> if (touchDelayUp.update()) {<br> if (touchDelayUp.fallingEdge()) {<br> if (touchDelay > 0) {<br> touchDelay = touchDelay - 10;<br> digitalWrite(led, HIGH);<br> delay(5);<br> digitalWrite(led, LOW);<br> }<br> }<br> }<br> if (touchDelayDown.update()) {<br> if (touchDelayDown.fallingEdge()) {<br> if (touchDelay < 200) {<br> touchDelay = touchDelay + 10;<br> digitalWrite(led, HIGH);<br> delay(5);<br> digitalWrite(led, LOW);<br> }<br> }<br> }<br> // Read all touch sensor wires:<br> touched = false;<br> for (c=0; c<t; c++) {<br> reading[c] = touchRead(touch[c]);<br> if (reading[c]-base[c] > sensitivity) {<br> touched = true;<br> }<br> }<br> // Comparing and delays do not happen if sensors are untouched:<br> if (touched); {<br> if (reading[0]-base[0] > sensitivity && reading[1]-base[1] < sensitivity) { // Top Only<br> Mouse.scroll(fast);<br> }<br> if (reading[0]-base[0] < sensitivity && reading[1]-base[1] > sensitivity) { // Up Only<br> Mouse.scroll(slow);<br> delay(touchDelay);<br> }<br> if (reading[0]-base[0] > sensitivity && reading[1]-base[1] > sensitivity) { // Top and Up <br> Mouse.scroll(medium);<br> delay(touchDelay);<br> }<br> if (reading[2]-base[2] > sensitivity && reading[3]-base[3] < sensitivity) { // Down Only<br> Mouse.scroll(-slow);<br> delay(touchDelay);<br> }<br> if (reading[2]-base[2] < sensitivity && reading[3]-base[3] > sensitivity) { // Bottom Only<br> Mouse.scroll(-fast);<br> }<br> if (reading[2]-base[2] > sensitivity && reading[3]-base[3] > sensitivity) { // Bottom and Down<br> Mouse.scroll(-medium);<br> delay(touchDelay);<br> }<br> if (reading[4]-base[4] > sensitivity) { // Left<br> Keyboard.press(KEY_LEFT);<br> Keyboard.release(KEY_LEFT);<br> }<br> if (reading[5]-base[5] > sensitivity) { // Right<br> Keyboard.press(KEY_RIGHT);<br> Keyboard.release(KEY_RIGHT);<br> }<br> delay(Delay);<br> }<br><br>}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.