© 2022 EasyEDA Some rights reserved
1.Easy to use and quick to get started
2.The process supports design scales of 300 devices or 1000 pads
3.Supports simple circuit simulation
4.For students, teachers, creators
1.Brand new interactions and interfaces
2.Smooth support for design sizes of over 30,000 devices or 100,000 pads
3.More rigorous design constraints, more standardized processes
4.For enterprises, more professional users
Std Editioncontador de cosas
License: Public Domain
const byte PIN_CLK = 9; // define CLK pin (any digital pin) const byte PIN_DIO = 8; // define DIO pin (any digital pin) TM1637Display display(PIN_CLK, PIN_DIO);
int PINO_TARA = 2; int PINO_20 = 3;
HX711 balanza(DOUT, CLK);
double tara = 0; double weight20 = 20;
void setup() { pinMode(PINO_TARA, INPUT); pinMode(PINO_20, INPUT);
display.setBrightness(0x0a);
Serial.begin(9600); Serial.print("Lectura del valor del ADC: "); Serial.println(balanza.read()); Serial.println("No ponga ningun objeto sobre la balanza"); Serial.println("Destarando..."); balanza.set_scale(); //La escala por defecto es 1 balanza.tare(20); //El peso actual es considerado Tara. Serial.println("Coloque un peso conocido:"); }
void loop() {
double weight = balanza.get_value(10); Serial.print("weight: "); Serial.println(weight);
if(digitalRead(PINO_TARA) == HIGH){ tara = weight; weight20 = tara + 10000; Serial.print("tara: "); Serial.println(tara); }
if(digitalRead(PINO_20) == HIGH){ weight20 = weight - tara; Serial.print("weight20: "); Serial.println(weight20); }
double weight1 = weight20 / 20; if(weight1 == 0) weight1 = 1; double weight1_2 = weight1/2;
double units = (weight - tara + weight1_2)/weight1; if(units < 0) units = 0;
Serial.print("Valor de lectura: "); Serial.println(units); //delay(100);
display.showNumberDec((int)units); }
Sheet_1
Open in editorID | Name | Designator | Footprint | Quantity |
---|---|---|---|---|
1 | Switch3x4x2 | X0,X20 | KEY-3.0*4.0 | 2 |
2 | 1k | R1,R2 | AXIAL-0.3 | 2 |
Unfold