Aula Jazmati
Published © MIT

Make A Digital Distance Meter With Hexabitz

Hello, in this project I will show you how to build your own distance meter box with Hexabitz modules.

IntermediateFull instructions provided1 hour254

Things used in this project

Story

Read more

Code

H08R6 code

C/C++
/*
 BitzOS (BOS) V0.2.7 - Copyright (C) 2017-2022 Hexabitz
 All rights reserved

 File Name     : main.c
 Description   : Main program body.
 */
/* Includes ------------------------------------------------------------------*/
#include "BOS.h"
float x;
int button1 = 0;
/* Private variables ---------------------------------------------------------*/

/* Private function prototypes -----------------------------------------------*/

/* Main function ------------------------------------------------------------*/

int main(void){

	Module_Init();		//Initialize Module &  BitzOS

	//Don't place your code here.
	for(;;){}
}

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

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

	// put your code here, to run repeatedly.
	while(1){

		    	if (button1 == 0){
		    		SetRangeUnit (UNIT_MEASUREMENT_CM);
		    		x = Sample_ToF ( );
		    		x = x- 4.0;
				    memcpy(&messageParams[0], &x, 4);
				    messageParams[4] = 2;
				    messageParams[5] = 'c';
				    messageParams[6]=0;
				    SendMessageToModule(2,CODE_H3BR6_SevenDisplayQuantities,7);	}
		    	if (button1 == 1){
		    		SetRangeUnit (UNIT_MEASUREMENT_INCH);
		    		x = Sample_ToF ( );
		    		x = x- 2.0;
		    		memcpy(&messageParams[0], &x, 4);
		    		messageParams[4] = 2;
		    		messageParams[5] = 'i';
		    		messageParams[6]=0;
		    		SendMessageToModule(2,CODE_H3BR6_SevenDisplayQuantities,7);	}
	}
}



void buttonClickedCallback(uint8_t port)
		{
			if(port == P3) 	{
				button1 = 1; IND_blink(200);

			}
			Delay_ms(10);

			}
void buttonDblClickedCallback(uint8_t port)
{

	if(port == P3) 	{
					button1 = 0; IND_blink(200);

				}
				Delay_ms(10);

}
/*-----------------------------------------------------------*/

H3BR6x-Firmware

H08R6x-Firmware

Credits

Aula Jazmati

Aula Jazmati

52 projects β€’ 215 followers
πŸ’‘πŸ•ŠοΈ

Comments