Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiweight dev #14

Merged
merged 4 commits into from
Sep 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}