I have a problem with programming a menu for selecting my programs for my robot.
The program has to show 9 numbers from 1 to 9 on a 7-segment display, representing a program(avoidance, linefollowing,....)
With 2 switches you go up or down a number and you comfirm with the 3the button(selecting the program you want). The 3 buttons are 1 input that gives a different value depending which button is pressed.
Now, the program I have written( in C) only gives a 9 when I start up the robot(not 1 of the buttons has effect on the numer appearing). I was wondering if you guys would help me find the solution to my robots problem.
Thanks, Danny
Here is my code.
void ShowNumber(void)
{
if(Number=1)
{
NumberOne();// Is showed on the display
}
if(Number=2)
{
NumberTwo();// Is showed on the display
}
if(Number=3)
{
NumberThree();// Is showed on the display
}
if(Number=4)
{
NumberFour();// Is showed on the display
}
if(Number=5)
{
NumberFive();// Is showed on the display
}
if(Number=6)
{
NumberSix();// Is showed on the display
}
if(Number=7)
{
NumberSeven();// Is showed on the display
}
if(Number=8)
{
NumberEight();// Is showed on the display
}
if(Number=9)
{
NumberNine();// Is showed on the display
}
}
void Choseprogram(void)
{
keuzesensor=a2dConvert8bit(3);
while(keuzesensor < 150 || keuzesensor > 110)// If the confirmbutton isn't pushed
{
keuzesensor=a2dConvert8bit(3);
if(keuzesensor > 170 && keuzesensor < 210)//1ste button
{
Number+=1;
delay_cycles(10500);
}
if(keuzesensor > 60 && keuzesensor < 90)//second button
{
Number-=1;
delay_cycles(10500);
}
if(Number> 9)
{
Number=9;
}
if(Number< 1)
{
Number=1;
}
ShowNumber();
delay_cycles(1000);
}