Question

Can someone help me translate some code from arduino project to netmf.. This is what i got from an arduino project:

int angle = 3000//angle is int 500 to 5500

unsigned int temp;
byte pos_hi,pos_low;

temp = angle & 0x1f80;  //get bits 8 thru 13 of position
pos_hi = temp >> 7;     //shift bits 8 thru 13 by 7
pos_low = angle & 0x7f; //get lower 7 bits of position

How would that translate to a netmf project in C#?

Was it helpful?

Solution

uint angle = 3000;//angle is int 500 to 5500

uint temp;
byte pos_hi,pos_low;

temp = angle & 0x1f80;  //get bits 8 thru 13 of position
pos_hi = (byte) (temp >> 7);     //shift bits 8 thru 13 by 7
pos_low = (byte) (angle & 0x7f); //get lower 7 bits of position
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top