Question
Modify the given code on a load sensor (weight sensor) to operate according to the following question. An Ardiuno Mega 2560 micro-controller is used to
Modify the given code on a load sensor (weight sensor) to operate according to the following question. An Ardiuno Mega 2560 micro-controller is used to operate the load cell.
#include "HX711.h" #define calibration_factor 1060.0 #define DOUT 3 #define CLK 2 HX711 scale(DOUT, CLK); char s[20]; //Declare a string variable for conversion result float weight; //Declare a float variable for weight value static FILE uart00 = {0};
void setup() { USART0_init(); //initialise USART0 parameters scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0 }
void loop() { weight= scale.get_units(); //Read from load cell if (weight (100-5) && weight
void USART0_init(void) { UCSR0A = B00000000; //single transmission speed, multiprocessor disabled UCSR0B = B00011000; //enable Rx & Tx UCSR0C = B00000110; //asynchronous, no parity, 1 stop, 8 bits UBRR0 = 103; //load the value for 9600 bps baud rate into whole UBRR register fdev_setup_stream (&uart00, TX, RX, _FDEV_SETUP_RW); //Associate RX and TX functions with stdin/stdout stdin= stdout = &uart00 ; //the uart is defined as the standard inputa/output device } static int RX(FILE *stream) { //do nothing until data is received and is ready to be read from UDR0; wait for USART RX Complete flag while ((UCSR0A & (1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started