I'm new to the Arduino world, and I purchased a micro to experiment with, and have the following project in mind:
What I would like to do is have the Arduino connected to a linear potentiometer, so that as it's slid up and down, the outputs in a PC/Mac/etc., would read it as an input (1-9) or move the mouse cursor along a single axis. How feasible is this to do and what code would it involve?
You'd need the Arduino USB to emulate a Human Input Device. There are different ways to achieve that depending which type of Arduino you use, but if you Google Arduino Mouse you'll get the idea.
One issue is that the potentiometer inherently gives you an absolute input position, but mouse events only contain relative movements. You will need some way to decide which potentiometer position to assume as the initial PC mouse position, so that you can send the appropriate movements subsequently. For example, if you know how big the display is you might choose to initialise the mouse position at startup by sending enough mouse movement events to ensure the mouse has reached the edge of the screen, and then bring it back to the position corresponding to the pot physical position.
If you intend to have the mechanical input directly control the mouse position in a repeatable way you would need to ensure that the PC didn't implement any form of mouse acceleration.
Googling Arduino mouse actually led me to a tutorial using Teensy. I'm assuming since the micro and the teensy use the same AT chip, the code should translate well.
Ideally the midpoint of the pot would serve as the middle of the sliding scale. So that would be the preferable origin position. There would be no up and down movement, just movement along a single axis, so in theory the slider would be the only thing controlling the mouse while it's being use, the actual mouse being left alone. If the movement output of the mouse was set to only affect a single axis, and the actual mouse was untouched while the slider was being used, would acceleration on the PC still be an issue, or is this a thing that would still need to be disabled?
If you want an absolute position of the potentiometer to correspond to an absolute position on the screen then you will need to ensure that the PC doesn't perform any mouse acceleration. In case you aren't familiar with it, the effect of mouse acceleration is typically that moving the mouse faster causes the screen pointer to move further, for the same mouse displacement. Without acceleration, moving the mouse by the same distance should always result in the pointer moving approximately the same distance.
So after looking at options, I feel like a linear soft touch potentiometer might be the best way to go for the physical application I want, since it seems to contain the least metal components (which is important for what I want to make), so the analogread will get a value from 0 to 1023. What's the best way to get that to translate into a cursor position output?
Sorry if this seems like a simple question, again I'm fairly new to this sort of application.
mattpriddle:
What's the best way to get that to translate into a cursor position output?
This seems to be a restatement of the original question, which was answered in Reply #1. You can't directly output a mouse cursor position. You can output mouse cursor movements, which can be used to achieve the same end result with some limitations i.e. you need to have a scheme to find the initial position of the mouse cursor, and I've suggested one scheme to you.