KRITSADA

POPX2 CMPS11 Compass Sensor Serial Mode Examples

Jun 27th, 2016
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. /*****************************************
  2. *   CMPS11 Serial example for Arduino    *
  3. *   Fork from James Henderson, 2014      *
  4. *****************************************/
  5. #include <popx2.h>
  6. unsigned char H,L;
  7. unsigned int angle;
  8. void setup(){
  9.   setTextSize(2);glcdMode(3);
  10.   glcd(3,0,"CMPS11");
  11. }
  12. void loop(){
  13.   uart1_putc(0x13);          
  14.   while(uart1_available() < 2);
  15.   H = uart1_getkey();L = uart1_getkey();
  16.   angle=(H<<8)+L;
  17.   glcd(0,0,"Angle=%d.%d ",angle/10,angle%10);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment