View previous topic :: View next topic |
Author |
Message |
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Sat Mar 20, 2021 11:06 am |
|
|
What about something like this:
Code: |
While(ir_code == 0xFF22DD)
output_high(PIN_A4);
delay_ms(500);
|
And the same code with PIN_A5? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Mar 20, 2021 11:39 am |
|
|
Don't sit there hanging on our every word. Just try it. If you have a
problem then post it. |
|
|
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Sat Mar 20, 2021 1:39 pm |
|
|
PCM programmer wrote: | Don't sit there hanging on our every word. Just try it. If you have a
problem then post it. |
Point taken, thanks |
|
|
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Sat Mar 20, 2021 2:04 pm |
|
|
Ttelmah wrote: | Of course it is.
If you just have the code for button 1 turn on it's pin, and turn the others
off, then button 2 does the same, 3 etc. etc..
Then if you push 1, this pin will go on, and all others off. Staying on
till another button is pressed. |
It works!! I added the “else” statement after each “if” statement, and the output_low() directive after. It now cycles through each button press. I appreciate all the patience with my discoveries.
I will post final code for this project when finished. |
|
|
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Sun Mar 21, 2021 1:37 pm |
|
|
Is it possible to isolate 2 of the PINS from the while loop, to where any changes to the other 3 don’t affect the 2? Thanks again. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 22, 2021 6:09 am |
|
|
Post your current while() loop so we can see what you're doing. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Mar 22, 2021 6:48 am |
|
|
You can probably 'mask' them.
'Masking' allows you to select or eliminate bits from bytes using logical AND and OR as required.
There may be info in the FAQ section of the manual, check some of the examples in the Example folder and of course ask Google ! |
|
|
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Mon Mar 22, 2021 9:57 am |
|
|
PCM programmer wrote: | Post your current while() loop so we can see what you're doing. |
I’ve decided to just go with the code as is for now, the original code, I will just have to toggle each switch for an on/off.
When I do the final design on the PCB, I will include a programming header on the board so that I can update the firmware, when I finally getting right.
Here is the code for the three pins(A0 - A2),using the “if-else” directive, and it works great, but the pins I want to use for the motorized potentiometer(A4,A5) are effected by this code.
Code: |
if(ir_code == 0xFF30CF)
output_high(PIN_A0);
else
output_low(PIN_A0);
if(ir_code == 0xFF18E7)
output_high(PIN_A1);
else
output_low(PIN_A1);
if(ir_code == 0xFF7A85);
output_high(PIN_A2);
else
output_low(PIN_A2);
|
I need to be able to isolate PIN_A4, and PIN_A5 from the other if -else statements. I’m going to put this one away for awhile and just use the original code. I have to now work on getting the Tx done. Thanks for the help. |
|
|
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Mon Mar 22, 2021 10:01 am |
|
|
temtronic wrote: | You can probably 'mask' them.
'Masking' allows you to select or eliminate bits from bytes using logical AND and OR as required.
There may be info in the FAQ section of the manual, check some of the examples in the Example folder and of course ask Google ! |
Thanks I’ll do some research on that. |
|
|
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Mon Mar 22, 2021 10:40 am |
|
|
temtronic wrote: | You can probably 'mask' them.
'Masking' allows you to select or eliminate bits from bytes using logical AND and OR as required.
There may be info in the FAQ section of the manual, check some of the examples in the Example folder and of course ask Google ! |
Something like this?
Code: |
void stepper(int8 step){
if(Direction == 0){
switch(step){
case 0: output_d(0b00000011); break;
case 1: output_d(0b00000110); break;
case 2: output_d(0b00001100); break;
case 3: output_d(0b00001001); break;
|
|
|
|
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Mon Mar 22, 2021 11:11 am |
|
|
temtronic wrote: | You can probably 'mask' them.
'Masking' allows you to select or eliminate bits from bytes using logical AND and OR as required.
There may be info in the FAQ section of the manual, check some of the examples in the Example folder and of course ask Google ! |
Something like this?
Code: |
void stepper(int8 step){
if(Direction == 0){
switch(step){
case 0: output_d(0b00000011); break;
case 1: output_d(0b00000110); break;
case 2: output_d(0b00001100); break;
case 3: output_d(0b00001001); break;
|
|
|
|
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Mon Mar 22, 2021 9:02 pm |
|
|
Just from reading the original code, there is nothing written in the code that tells the chip what to do when there are no commands coming from the IR sensor. From code we don’t know the state of the input pin, A3(low or high), so it’s only acting on the hexadecimal commands being sent by the transmitter, not what isn’t sent. I very well could be wrong and it wouldn’t be the first time.
I have a program for a 10F200, using SIRC protocol, that has just 3 outputs, 2 of which can be changed from latched to momentary by changing only a few directives. But it’s written in assembly code, a mile long!! It does a good job on my volume Control but very limited. |
|
|
|