资讯详情

如何使用Arduino进行编程 通通过压力传感器控制电机转速

/*

* circuits4you.com

* 2016 November 25

* Load Cell HX711 Module Interface with Arduino to measure weight in Kgs

Arduino

pin

2 -> HX711 CLK

3 -> DOUT

5V -> VCC

GND -> GND

Most any pin on the Arduino Uno will be compatible with DOUT/CLK.

The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.

*/

#include "HX711.h"//You must have this library in your arduino library folder

#define DOUT3

#define CLK2

HX711 scale(DOUT,CLK);

//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands

float calibration_factor = -9650worked for my 40Kg max scale setup

//=============================================================================================

// SETUP

//=============================================================================================

void setup()

Serial.begin(9600);

Serial.println("Press T to tare");

scale.set_scale(-96650);//Calibration Factor obtained from first sketch

scale.tare(); //Reset the scale to 0

}

//=============================================================================================

// LOOP

//=============================================================================================

void loop() {

Serial.print("Weight: ");

Serial.print(scale.get_units(),3);//Up to 3 decimal points

Serial.println(" kg"); //Change this to kg and re-adjust the calibration factor if you follow lbs

if(Serial.available())

{

char temp = Serial.read();

if(temp == 't' || temp == 'T')

scale.tare();//Reset the scale to zero

}

}

//=============================================================================================

标签: 薄膜式压力传感器arduino

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台