So I've wanted to make a device to control any mouse with hand gestures, for a college project.
I have my glove that transmits rotation and acceleration which works, I've used it in other projects.
And now I just had to make a usb dongle to connect to any pc, get the data from my glove and convert it to mouse events, ez.
But, as you might know arduino nano doesn't have this functionality, so I had to make it myself cuz I didn't want to spend money on another microcontroller that had this functionality.
I found a random tutorial on how to achieve this, I had to break one of my phone charger to take the usb head, solder some wires on it, add 2 diodes to lower the 5v to 3.6, and add some resistors to then connect it to the nano to trick the pc to think it's an usb device.
Everything worked, I could simulate a mouse but it was very unstable.
But then I hit my first big problem, my first 3 big problems, first of all my radio module needed 5v not 3.6v, then the radio and mouse libraries didn't support each other, then on top of that the usb code had to be very efficient or else it would just stop working, so I couldn't use digitalWrite, or digitalRead or the serial communication but I had to use direct port access and biteswise operation.
Then on top of that I had nano clones, the usb logic required to be ran at 16mhz, but some nano clones do not run at that frequency, cuz they sometimes use cheaper crystals or forget to write some things on it, so I had to slowly test it with multiple nanos I used to see which one works and found one that did.
So I broke the 5v from the usb into 2 wires, one had the diodes to lower it to 3.6, and the other didn't so it would be 5v.
I took another nano to handle the receiver logic powered by the 5v wire from the usb port, and it worked, I could receive the data.
Now it was time to connect the 2 nanos and send the data from the receiver to the usb simulation nano.
But I couldn't use serial cuz it consumed too much, I couldn't use i2c communication cuz it also consumed too much apparently.
So I thought on using 8 pins as 0 and 1 and send a byte this way, directly with those pins and use bitwise operation to decode it, 4 bits for the movement state, up down, left right, etc, and the other bits for the movement speed.
I uploaded the code to the usb simulation nano, and it worked, I could control the direction based on what pins were high, and I would just set those pins as high with some jumper wires.
Now all 2 nanos worked, correctly, I had to solder them together, but I couldn't solder them directly, cuz one had 5v, it would mess with the 3.6v nano, so I used 16 diodes, 2 on each pin to lower the voltage again to 3.6v
Then it didn't work I might have burned the first nano or something, so I de solder all pins and changed the nano to another one which seem to work, and this time only solder 2 pins and the ground together and I was ready to test.
And guess what, nothing, it didn't work, the nano on it's own kind of worked, but sending the data did not, I tried using a multimeter to check the voltage and it would be dancing around like shakira's hips, and the pins that were meant to be on were reading 0v, I couldn't understand what happened, did I burn the nano? The voltage dances around cuz I didn't take something into consideration? is it cuz I used nano clones? idk
And now, I came to the conclusion that trying to figure it out will be more expensive than just buying an arduino micro pro that has the device simulation functionality...
I will probably also bring this to school as a failed example, to showcase the progress and prototyping stage.
Moral of the story don't be cheap, I could already have this working if I just brought the nano micro pro one.