Skip to content

Commit

Permalink
Simplify pinout definitions by not trying
Browse files Browse the repository at this point in the history
to use constants for digital pins at all
  • Loading branch information
amotl committed Feb 20, 2019
1 parent 7d75502 commit 83c9f51
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 45 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@ It supports the platforms `atmelavr`, `espressif8266`, `espressif32`,
#include "HX711.h"
HX711 loadcell;

// 1. Loadcell settings

// AVR and friends
const int LOADCELL_DOUT_PIN = A1;
const int LOADCELL_SCK_PIN = A0;

// ESP and friends
const int LOADCELL_DOUT_PIN = D2;
const int LOADCELL_SCK_PIN = D3;
// 1. HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;

// 2. Adjustment settings
const long LOADCELL_OFFSET = 50682624;
Expand Down
15 changes: 6 additions & 9 deletions examples/HX711_basic_example/HX711_basic_example.ino
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
#include "HX711.h"

// CIRCUIT:
// HX711 DOUT TO PIN 2
// HX711 PD_SCK TO PIN 3
//
// Pin definitions D2 and D3 are provided by "nodemcu" board,
// see `nodemcu/pins_arduino.h`.
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;

HX711 scale;

void setup() {
Serial.begin(57600);
scale.begin(D2, D3);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
}

void loop() {

if ( scale.is_ready() ) {
if (scale.is_ready()) {
long reading = scale.read();
Serial.print("HX711 reading: ");
Serial.println(reading);
} else {
Serial.println("HX711 was not found or not ready.");
Serial.println("HX711 not found.");
}

delay(1000);
Expand Down
21 changes: 6 additions & 15 deletions examples/HX711_full_example/HX711_full_example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,13 @@
* (c) 2018 Bogdan Necula
*
**/
#include "HX711.h"

/**
*
* Pin definition examples
*
* AVR and friends
* HX711.DOUT - pin #A1
* HX711.PD_SCK - pin #A0
*
* ESP and friends
* HX711.DOUT - pin #D2
* HX711.PD_SCK - pin #D3
*
**/

#include "HX711.h"
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;


HX711 scale;

Expand All @@ -38,7 +29,7 @@ void setup() {
// - With a gain factor of 32, channel B is selected
// By omitting the gain factor parameter, the library
// default "128" (Channel A) is used here.
scale.begin(A1, A0);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

Serial.println("Before setting up the scale:");
Serial.print("read: \t\t");
Expand Down
8 changes: 4 additions & 4 deletions examples/HX711_retry_example/HX711_retry_example.ino
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "HX711.h"

// CIRCUIT:
// HX711 DOUT TO PIN 2
// HX711 PD_SCK TO PIN 3
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;

HX711 scale;

void setup() {
Serial.begin(57600);
scale.begin(D2, D3);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
}

void loop() {
Expand Down
8 changes: 4 additions & 4 deletions examples/HX711_timeout_example/HX711_timeout_example.ino
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "HX711.h"

// CIRCUIT:
// HX711 DOUT TO PIN 2
// HX711 PD_SCK TO PIN 3
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;

HX711 scale;

void setup() {
Serial.begin(57600);
scale.begin(D2, D3);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
}

void loop() {
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/bogde/HX711.git"
},
"version": "0.6.0",
"version": "0.7.1",
"exclude": "tests",
"examples": "examples/*/*.ino",
"frameworks": "arduino",
Expand Down
4 changes: 1 addition & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ include_dir = .

[config]
build_flags =
-D D2=2
-D D3=3
-D VERSION=1.2.3
-D VERSION=0.7.1
-D DEBUG=1

src_filter =
Expand Down

0 comments on commit 83c9f51

Please sign in to comment.