Hi!
Im trying to get a rotary encoder working but its just to advanced for me...
This is the code i tried to write but its not the right way to do it...
And i just dont know how to think...
Can someone help me in the right direction here?
int rot = (0x0000);
while(1)
{
if (!GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1))
{
rot = 1;
rot<<=1;
}
if (!GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_2))
{
rot = rot + 1;
rot<<=1;
}
if (!GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1))
{
rot = rot + 1;
rot<<=1;
}
if (!GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_2))
{
rot = rot + 1;
rot<<=1;
}
if (rot == 1 || rot == 7 || rot == 8 || rot == 14)
{
a[0] = a[0] + 34360;
}
if (rot == 2 || rot == 7 || rot == 8 || rot == 14)
{
a[0] = a[0] - 34360;
}
rot = 0;
}