Hmmm, I re-downloaded the original file that the author sent me and tried again. For some reason now it works perfectly. I modified the intro text with all 0s again and they're all there this time. I have no idea why. For some reason it doesn't show the bar graph in my simulator even with the unmodified code and since I broke my display I will have to wait til I get a new one to see if the bar graph is actually working properly. Again though, before it wouldn't display anything on the last column and now it does. Really weird.
I have encased what used to be the old intro text into an if statement and the while(1) loop immediately following it, which makes up the bargraph, is now an else. I am using RB7 as an input and it toggles between if and else. This is so that when I push the button the screen goes from the menu to the bar graph. I figured out how to display variables and I've set up "soundno" as the variable representing the sound number to be played.
The additions/changes look something like this, obviously trimmed down for simplicity.
Code:
void main(){
unsigned int soundno=0;
if(RB7=1){
write_lcd_string("SOUND:");
goto_lcd(0x06);
write_lcd_number(soundno,10,2,0);
}
else {
//bargraph code
} //end of bargraph code
} //end of main
When I do this in the simulator the screen does indeed change depending on the state of RB7 but as I said earlier, even with the original unmodified code the simulator doesn't show the bargraph so whether or not this actually displays the bargraph when RB7 goes low will be seen once I get my new display.
For now I am trying to figure out how to increment variable soundno using RB6. I tried using an if statement within the first if statement but I guess that's a dumb idea,
Code:
If(RB7=1){
if(RB6=0) //lame attempt at incrementing soundno when RB6 goes low
{++soundno;
__delay_ms(30);} //lame attempt at debouncing
write_lcd_string("SOUND:");
goto_lcd(0x06);
write_lcd_number(soundno,10,2,0);
}
When I power the circuit soundno is already displayed as 1 even though the initial value is 0 and when I press the button to make RB6 go low it makes soundno go to 0 and once I release the button it makes it go back to 1.
On the display it looks like this
Power on the circuit
SOUND:1
Press button
SOUND:0
Release button
SOUND:1
I'm obviously doing something hilariously wrong, I could use your advice.
Thanks.