จะทำโปรเจ็คครับ เป็นเครื่องชั่งน้ำหนักครับ
มีจอแสดงค่าน้ำหนัก โดยสามารถตั้งพิกัดของน้ำหนักได้ เมื่อถึงพิกัดที่กำหนด จะทำให้ output 1 ทำงานครับ
โดยสามารถเลือกพิกัดน้ำหนักได้ 4 ขนาด 620g/740g/470g/440g
สมุติ กด เลือกพิกัดน้ำหนัก 620
เครื่องจะทำงานโดยมีของเหลวไหลลงมาตรง loadcell เมื่อถึง 620 กรัม
จะทำให้ output 1 ทำงาน
อยากทราบว่าผมต้องใช้อุปกรณ์อะไรบ้างครับ
ตอนนี้ผมได้ของครบตามต้องการเเล้วครับ
ผมใช้ โค๊ดนี้อะครับ แต่ติดอยู่ที่ว่าผมไม่รู้จะนำค่าที่อ่านได้ไปแสดงบน Seven Segment 4-Digit Display Tube LED Display Module With Clock Display Board For Arduino (Catalex) ตัวนี้ยังไงอะครับ
ตรงที่บทเรียนข้างบนไม่ได้สอนไว้อะครับ T^T
#include "HX711.h"
// HX711.DOUT- pin #A1
// HX711.PD_SCK- pin #A0
HX711 scale(A1, A0);// parameter "gain" is ommited; the default value 128 is used by the library
void setup() {
Serial.begin(38400);
Serial.println("HX711 Demo");
Serial.println("Before setting up the scale:");
Serial.print("read: \t\t");
Serial.println(scale.read());// print a raw reading from the ADC
Serial.print("read average: \t\t");
Serial.println(scale.read_average(20)); // print the average of 20 readings from the ADC
Serial.print("get value: \t\t");
Serial.println(scale.get_value(5));// print the average of 5 readings from the ADC minus the tare weight (not set yet)
Serial.print("get units: \t\t");
Serial.println(scale.get_units(5), 1);// print the average of 5 readings from the ADC minus tare weight (not set) divided
// by the SCALE parameter (not set yet)
scale.set_scale(2280.f); // this value is obtained by calibrating the scale with known weights; see the README for details
scale.tare(); // reset the scale to 0
Serial.println("After setting up the scale:");
Serial.print("read: \t\t");
Serial.println(scale.read()); // print a raw reading from the ADC
Serial.print("read average: \t\t");
Serial.println(scale.read_average(20)); // print the average of 20 readings from the ADC
Serial.print("get value: \t\t");
Serial.println(scale.get_value(5));// print the average of 5 readings from the ADC minus the tare weight, set with tare()
Serial.print("get units: \t\t");
Serial.println(scale.get_units(5), 1); // print the average of 5 readings from the ADC minus tare weight, divided
// by the SCALE parameter set with set_scale
Serial.println("Readings:");
}
void loop() {
Serial.print("one reading:\t");
Serial.print(scale.get_units(), 1);
Serial.print("\t| average:\t");
Serial.println(scale.get_units(10), 1);
scale.power_down(); // put the ADC in sleep mode
delay(5000);
scale.power_up();
}
โคดตัวอย่าง 7 segment Catalex ตามนี้ครับ
ไลบารี DigitalTube For Arduino
ถ้าเป็นชั่งน้ำหนักที่มีจุดทศนิยมตัว 7 segment Catalex จะแสดงจุดในลักษณะของนาฬิกา
ลองดูโมดูลตัวนี้เป็นตัวเลือกอีกตัวครับ แก้โคด 2 บรรทัดก็แสดงเลขที่ต้องการได้แล้ว
การใช้งาน โมดูลแสดงค่าตัวเลข 4 หลัก Four digital tube module LED display
‹ ก่อนหน้า | 1 | 2 |