Aula Jazmati
Published © MIT

DIY Inclinometer Using Hexabitz Modules

This project helps you measure the angle of a surface with respect to earth's gravitational field using Hexabitz modules.

IntermediateFull instructions provided1 hour304
DIY Inclinometer Using Hexabitz Modules

Things used in this project

Story

Read more

Schematics

The Schematics

Code

H0BR4 Module Code

C/C++
#include "BOS.h"
#include "math.h"
float x, y, z, ang2;
int button1 = 0;
int main(void){

	Module_Init();		//Initialize Module &  BitzOS
	
	//Don't place your code here.
	for(;;){



	}
}



/*-----------------------------------------------------------*/

/* User Task */
void UserTask(void *argument){
AddPortButton(MOMENTARY_NO,P1);
SetButtonEvents(P1, 1, 1, 0, 0, 0, 0, 0, 0, 0);

	// put your code here, to run repeatedly.
	while(1){
    	SampleAccG (&x, &y, &z);
    	if (button1 == 0){
    		ang2 = (atan2(-x,z))* 57.3;
		    memcpy(&messageParams[0], &ang2, 4);
		    messageParams[4] = 2;
		    messageParams[5] = 'd';
		    messageParams[6]=0;
		    SendMessageToModule(2,CODE_H3BR6_SevenDisplayQuantities,7);	}
    	if (button1 == 1){
    		ang2 = atan2(-x,z);
    		memcpy(&messageParams[0], &ang2, 4);
    		messageParams[4] = 2;
    		messageParams[5] = 'r';
    		messageParams[6]=0;
    		SendMessageToModule(2,CODE_H3BR6_SevenDisplayQuantities,7);	}
	}
}

void buttonClickedCallback(uint8_t port)
		{
			if(port == P1) 	{
				button1 = 1; IND_blink(200);	}
			Delay_ms(10);
			}

/*-----------------------------------------------------------*/

H3BR6x-Firmware

H0BR4x-Firmware

Credits

Aula Jazmati

Aula Jazmati

49 projects β€’ 193 followers
(PhD) in Electronic Engineering 2023 πŸ’‘πŸ•ŠοΈ

Comments