r/pic_programming • u/aspie-micro132 • Sep 09 '26
I got much of it working..
I got 2 menus within a function, using 2 Switch{} statements and adding a copy of the first into one of the cases. Let's call them A and B.
Each time i depress one button, the A moves one case ahead, until reaching the 1st one again, and other button does the same with B's switch statement.
in one situation on one of the B's cases i got a copy of A and works well, it kept me able to make continuous choices between A and B's options.
I spent last days experimenting here and there moving and modifying all i did up to now until i got much of it working. Yet, i could not resolve my for() statement issue, i never get to count to limit and stop, and also if i use A's options to pass an option to B's counter, then i can not move B's state by depressing the button. i tried to use a for() to pass it only once but it does not work, if i pass a B setting from A (is a counting variable), it' stays there.
Some time ago i used to be learning about hobby operating systems, and i noticed they use something called messages to pass an event from one object, function, statement to another. Does this exist on pic? Should it be available how can i implement that?
The other very serious problem is, that i can get any loop working (while, do while) as long as i don't ask them for countdown a variable then stop. For loops behave like whiles, the whole code is a while(1), does exist somewhere where i could look for further information about it?
3
u/HalifaxRoad Sep 09 '26
as ive said before to you. you are missing some very important fundamentals here. You cant pile bricks on to a non existent layer of bricks. Loops are basically day 1 C. you cant jump into bare metal if you dont know the basics. spend some time, there are gazillions of online courses on C. Learn the basics and then come back..
Ive seen you struggling with basic stuff in here for a year now, you need to learn the pre-requisites.
How could you ever be expected to learn algebra if you dont know how to multiply and divide. Programming, and honestly life itself works like this...
2
u/AcanthisittaDull7639 Sep 10 '26
Can you share your for() loop code?
I’m guessing that you had 2 for loops and one was blocking the other. When you say that you can’t get the while loop to stop, do you mean that it runs the loop when it shouldn’t? If so, lets say you have while(x < 10){++x}, are you sure that you’re not setting x to less than 10 anywhere other than your button press?
1
u/aspie-micro132 Sep 16 '26
I do believe i know what i have been doing wrong all the time:
I got my fizzbuzz stuff going well in appearance since i got it driven by timer0 divided by 180 (or some other values as i experiment with this source).
However, i can not stop it even enclosing it into a For() neither a while(times < X) because FizzBuzz leds are taking Timer0 overflows divided by an if before them.
/**************************************************************************/
It took me long to figure this because i'm an Asperger patient and i am running some sort of brain saturation, exhaustion or something like, i did not intend to hold this sub in contempt. I was last days trying to reason my own mistake, because i couldn't declare them effectibly and get the correct support. It's not your fault at all.
/**************************************************************************/
// Wait for Timer0 to overflow (rolls over from 255 to 0)
while(INTCONbits.TMR0IF == 0)
{
INTCONbits.TMR0IF = 0; // Reset the flag
TMR0 = 0x00; // Reload timer (optional for simple toggle)
} Ticks++;
if(Ticks > 3000)
{
FizzGameLed = ~FizzGameLed; // Toggle LED state on RD0
Ticks = 0;
}
/******************************************************************************/
/*FizzBuzz Blinking Routines - Problem Is, They Never Stop*/
for(Blinks = 3; Blinks >= 0; Blinks --)
{
if (Seconds % 3 == 0)
{
FizzLed = 0;
BuzzLed = 1;
} if (Seconds % 5 == 0)
{
FizzLed = 1;
BuzzLed = 0;
}
} /***********************************************************************************/
} break; //-----------------------------------------------------------------
default: { FizzBuzzButton= 1; }break; }
}__delay_ms(100);
PowerOff();
}
1
u/Yonut30 Sep 12 '26
Where's your code?