Skip to content

Commit

Permalink
Update led_and_scale.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukkoz committed Jul 7, 2021
1 parent b6ab9b3 commit 73ee7db
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions Atmega_Soft/led_and_scale/led_and_scale.ino
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ long LeftRead;
long RightRead;

HX711 LeftScale;
//HX711 RightScale;
HX711 RightScale;
char out_buffer[32];
byte frame[6];

Expand All @@ -123,7 +123,7 @@ void setup() {
Wire.onReceive(receiveEvent); // register event
Wire.onRequest(requestEvent);
LeftScale.begin(SCALE1_DT, SCALE1_SCK, 64);
//RightScale.begin(SCALE2_DT, SCALE2_SCK, 64);
RightScale.begin(SCALE2_DT, SCALE2_SCK, 64);

#ifdef DEBUG
Serial.begin(9600); // start serial for output
Expand Down Expand Up @@ -300,13 +300,6 @@ long measure_weight1() {
long WL = 0;
long weightLT[5];
int i = 0;

while(!LeftScale.is_ready()){

}
LeftScale.set_gain(64);


while(true){
if(digitalRead(PowerButtonInterruptPin) == HIGH)PowerButtonPressed();
if(LeftScale.is_ready()) {
Expand All @@ -331,6 +324,8 @@ long measure_weight1() {
minid = jj;
}
}


for(byte kk = 0; kk <5 ; kk++){
if(kk != maxid && kk != minid) WL += weightLT[kk];
}
Expand All @@ -342,19 +337,11 @@ long measure_weight2() {
long WR = 0;
long weightRT[5];
int i = 0;
while(!LeftScale.is_ready()){

}
LeftScale.set_gain(32);
while(true){
if(digitalRead(PowerButtonInterruptPin) == HIGH)PowerButtonPressed();
/*if(RightScale.is_ready()) {
if(RightScale.is_ready()) {
weightRT[i] = RightScale.read_average(2);
i++;
}*/
if(LeftScale.is_ready()) {
weightRT[i] = LeftScale.read_average(2);
i++;
}
if(i == 5)break;
}
Expand All @@ -378,6 +365,8 @@ long measure_weight2() {
for(byte kk = 0; kk <5 ; kk++){
if(kk != maxid && kk != minid) WR += weightRT[kk];
}


return(WR/3);
}

Expand Down Expand Up @@ -634,9 +623,4 @@ void PowerButtonPressed(){
digitalWrite(SlaveFlagPin,LOW);
delay(2500);
}
}





}

0 comments on commit 73ee7db

Please sign in to comment.