| Posted: 12:43am 15 Oct 2024 |
|
|
|
Some thoughts on using a Pico for this.
As noted above, it would be easiest to replace both IC201, IC202 and associated transistors with the PicoMite.
The inbuilt IR command does not decode the "Repeat" pulses that the remote outputs to indicate a continuous button press, so to continuously raise / lower the volume needs a work-around. <Edit> Tested a couple of remotes. After a few hundred mS of repeat pulses they repeat the whole code so you may not need to worry about this. The code below has been edited to take advantage of this by reducing the timeout to 500mS.
The output variables of IR DevCode, KeyCode, IRInt hold their values until another button is pressed. You can use that to advantage by stopping the motor when any other button is pressed. The volume could steadily raise / lower until that is pressed or the time-out is reached.
A starting point for the code could be something like:-
Const Up% = (270 << 8) + 227 '270=DevCode and 227=KeyCode for Up Button Const Down% = (270 << 8) + 19 '270=DevCode and 19=KeyCode for Down Button Const Pon% = (270 << 8) + 3 '270=DevCode and 3=KeyCode for On Button Const Poff% = (270 << 8) + 249 '270=DevCode and 249=KeyCode for Off Button
SETPIN GP0, IR SETPIN GP1, Dout 'Vol up SETPIN GP2, Dout 'Vol down SetPin GP3, Dout 'Power
IR DevCode, KeyCode, IRInt
Sub IRInt T = Timer DevKey = (DevCode <<8) + KeyCode
if DevKey = Up% then pin(gp1) = 1 pin(gp2) = 0 endif
if DevKey = Down% then pin(gp1) = 0 pin(gp2) = 1 endif
if DevKey = if (DevKey <> Up%) and (DevKey <> Down%) then 'quick stop pin(gp1) = 1 'Both high for braking pin(gp2) = 1 pause 200 'braking period pin(gp1) = 0 pin(gp2) = 0 endif 'Select Case would be better but that is the idea.
If DevKey = Pon% Then Pin(gp3) = 1
If DevKey = Poff% Then Pin(gp3) = 0
End Sub
Do If (Timer - T) > 500 then 'set a time limit for the motor run time pin(gp1) = 0 pin(gp2) = 0 endif loop End Another option would be to modify my NEC IR Receiver program to also decode the Repeat pulses.
Edit. The code above is tested and working (with different IR codes and driving LEDs rather than a pot). Edited 2024-10-15 16:56 by phil99
Footnote added 2024-10-15 21:15 by phil99 Just noticed a careless copy/paste in the code above. This line:- if DevKey = if (DevKey <> Up%) and (DevKey <> Down%) then 'quick stop shoold be:- if (DevKey <> Up%) and (DevKey <> Down%) then 'quick stop |