Linear pot and webpage

Hello,

i'm looking for a simple way to transfer pot value from my µc to a webpage on a mobiledevice.
My pot and µc are plugged into my mobile trough usb

Yes lot of things.

i'm able to use send pot value by midi protocole, but this is not compliant with mobile browser (no web midi api)
mytest

i've tried USBHid lib to send value as an "hid message" (find script in the doc ) but i'm unable to received usable value sent in the browser, i received charcode for digit value... don't understand why!

I've tried to send value (0-127) as charcode but some value are unavailable as charcode. and i'm unable to translate in digit value as keyEvent.key give only char not charCode. (unable to translate to digit)

I've tried sometime ago MouseHID but in my "souvenir" it was not as usefull as excepted when mouse move value push the pointer(cursor) out of the screen size (have to try again to be sure).

Have you any idea to share?

best regards

éric

there is experimental stuff like this you could explore

requires https

Hello,

i saw it
it works only in chrome mobile
no Firefox, no Safari :frowning:

i'm able to received correct value with a String() in arduino code

Keyboard.println(String(counter%128));

in my html page, i fill an array with values til 'Enter' and join the array
not really pretty, but it works

window.addEventListener("keydown", (event) => {
    if (event.key !== undefined) {
      // Handle the event with KeyboardEvent.key
      switch (event.code) {
        case 'Enter':
          document.body.innerHTML = parseInt(table[index].join(""));
          index++;
          table[index] = [];
          break;
        default:
          table[index].push(event.code.replace(/Digit/g,""));
      }
      //document.body.innerHTML += `${event.code.replace(/Digit/g,"").replace(/Enter/g,"<br>")}`;
    } else if (event.which !== undefined) {
      // Handle the event with KeyboardEvent.which
    }
  });

works too in Firefox iOS with µc plugged in the ipad :partying_face:

sure it's a major security breach and needs to be managed super carefully :wink:

this approach

is just by pretending to be a keyboard. that's an option if the cursor is in the right field and ready to receive text input, like someone was typing on a keyboard

yes! this is exactly what i want.
i search a simple solution easy to install on a phone or tablet.
it is for playing with a linear pot and pictures sequences on a mobile phone or desktop.
love web tech, easy to code, browser are on all mobile...
can code a wepapp and cache all images and it'll work offline.

when webpage has the focus (default behaviour on mobile browser) page received keystroke...

:v:

Keyboard.println(counter%128);

works too

received "Digit1Digit0Digit0Enter" for 100 sent
then need to clean the output

window.addEventListener("keydown", (event) => {
    if (event.key !== undefined) {
      switch (event.code) {
        case 'Enter':
          // transform string to number
          potValue = parseInt(table.join(""));
          // write in body
          document.body.innerHTML = potValue;
          // or do what i want with this numeric value
          // reinit array
          table = [];
          break;
        default:
          // remove "Digit" in the string and push in the array
          table.push(event.code.replace(/Digit/gm,""));
      }
    }
});

then that works :slight_smile:

Hi, @mrbbp
Random Nerd is a good site to look for those sorts projects.

Tom... :smiley: :+1: :coffee: :australia:

Thanks @TomGeorge for the link (don't know it)

it's done, i did it with my dirty code. It's working!
i used an exen mini from nerdonic (arduino zero with small formfactor

and i share code on github

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.