I've given myself a project - to build electronic gear shifters for my bike with my Arduino uno.
So far, I've finished what I'd consider to be a proof of concept. Two push buttons for shifting up and down, a hardcoded array of positions and a servo that jumps between each of those positions as and when a button is pushed. I'm a complete beginner so I'm still surprised just to get this far.
Anyway, I'm now thinking of the practicalities of how it'll actually work and I could do with some help in actually bringing it to life. The plan is to run it on one of those USB power banks. This leaves me with a problem however.
Power consumption. I'd like to automatically power down when I'm not changing gear; running out of power and being stuck in a single gear wouldn't be ideal. I understand that you can effectively put the board to sleep, although this isn't massively beneficial on unos (wouldn't be averse to changing board but I'm not sure that would fix things anyway). Interestingly, my power bank cuts out if it the power drawn from it remains below a threshold for 30s, and that threshold is above the power consumed just to run the board and below the amount required to move the servo. So everything stays powered up until I go for 30s without shifting, which is pretty much perfect.
Unfortunately, this leaves me with a long list of other problems.
Waking the power supply back up again. There's a button on the power bank that wakes it back up again. I've thought about opening this up and wiring up both of my shifter buttons to this but unsure how to go about it. They are straight forward 2 pin push buttons - given that, when everything is live, there's 5V from the Arduino going through them, would this damage the power bank? I feel like I'd ideally want a push button that's capable of completing 2 entirely separate connections at once, not sure if that's a thing.
Responsiveness when waking up. Ideally, the power supply would turn on with one push of the button and immediately shift accordingly. At very least, I'd want to be able to get to the stage of pressing the button once to switch on, then again a second or so later to tell the Arduino to shift. Is that realistic?
Stopping the servo's random movements when the power comes on. At the moment, whenever the power supply is turned on, the servo wobbles about a bit before settling on the spot it's supposed to be in. That's obviously not practical if I'm riding along - is that something that all servos always do or is there more likely something up with my code?
Knowing where the servo is when the power supply comes back on. My understanding is that the Arduino will forget any variables that have been defined when it turns back on. So without feedback from the servo, it won't know what the current gear is and it won't know what gear to shift to when I push a button. Any chance there's a way around this? I've seen customised servos that have been wired up so that the internal potentiometer can be read, so I guess that's always an option.
As you can see, I'm basically just dumping everything in my brain onto this forum. As you can probably also see, I don't entirely know what I'm doing! So any helpful nudges in the right direction from anyone with a bit of knowledge would be greatly appreciated.