Skip to content

Commit

Permalink
Merge pull request #14 from circuitar/multiweight-dev
Browse files Browse the repository at this point in the history
Multiweight dev
  • Loading branch information
ddmendes committed Sep 17, 2015
2 parents 4881024 + 5df2d25 commit fbee381
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions examples/MultiWeight/MultiWeight.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* @file MultiWeight.ino
* Read multiple load cells using the ADS1230 IC in the LoadCell Nanoshield.
*
* This example uses the following default settings for both load cells:
Expand All @@ -11,28 +12,59 @@
#include <SPI.h>
#include <Nanoshield_LoadCell.h>

// Load cell 1: 30kg capacity and 10mV/V sensitivity on pin D7
Nanoshield_LoadCell lc1(30000, 10, 7);
// Load cell 1: 30kg capacity and 10mV/V sensitivity on pin D4
Nanoshield_LoadCell lc1(30000, 10, 4);

// Load cell 2: 100kg capacity and 3mV/V sensitivity on pin D7
Nanoshield_LoadCell lc2(100000, 3, 7);

// Load cell 2: 50kg capacity and 2mV/V sensitivity on pin D8
Nanoshield_LoadCell lc3(50000, 2, 8);

// Load cell 2: 150kg capacity and 2mV/V sensitivity on pin D10
Nanoshield_LoadCell lc4(150000, 2, 10);

// Load cell 2: 100kg capacity and 1.5mV/V sensitivity on pin A3
Nanoshield_LoadCell lc5(100000, 1.5, A3);

// Load cell 2: 100kg capacity and 3mV/V sensitivity on pin D8
Nanoshield_LoadCell lc2(100000, 3, 8);

void setup() {
Serial.begin(9600);
lc1.begin();
lc2.begin();
lc3.begin();
lc4.begin();
lc5.begin();

// Wait for calibration and set current value to zero weight (tare)
while (!lc1.updated() || !lc2.updated());
while (!lc1.updated()
|| !lc2.updated()
|| !lc3.updated()
|| !lc4.updated()
|| !lc5.updated());

lc1.setZero();
lc2.setZero();
lc3.setZero();
lc4.setZero();
lc5.setZero();
}

void loop() {
if (lc1.updated() && lc2.updated()) {
if (lc1.updated()
&& lc2.updated()
&& lc3.updated()
&& lc4.updated()
&& lc5.updated()) {
Serial.print(lc1.getWeight(), 0);
Serial.print("g,");
Serial.print("g, ");
Serial.print(lc2.getWeight(), 0);
Serial.print("g, ");
Serial.print(lc3.getWeight(), 0);
Serial.print("g, ");
Serial.print(lc4.getWeight(), 0);
Serial.print("g, ");
Serial.print(lc5.getWeight(), 0);
Serial.println("g");
}
}

0 comments on commit fbee381

Please sign in to comment.