From Arduino to Panda 2

Hi
ive been looking at some Arduino code, that does some stuff that i would like to do in netmf instead.
But not sure how it would translate to c#…

This is the Arduino code:


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

Anyone who is familiar with both languages, that might be able to help me out?

int angle = 3000;//angle is int 500 to 5500
 
int 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

Shouldn’t it be…

uint temp;

yes, it should :slight_smile: If I thought I could get away with it, I’d say that was a deliberate change put in there to see who was paying attention (Ian) but I can’t; I forgot I’d chopped unsigned off and didn’t U it.