David PotterPhil Brown
Published

The Perfect Shot

A device that informs the user when to stop pouring fluid into a shot glass in order to obtain the "perfect shot".

BeginnerFull instructions provided388
The Perfect Shot

Things used in this project

Hardware components

Argon
Particle Argon
×2
LED, RGB
LED, RGB
×1
Digital Load Cell Weight Sensor HX711 AD Converter Breakout Module 5kg
×1
LCD 1602 Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×2
Resistor 4.75k ohm
Resistor 4.75k ohm
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Wiring Diagram for the LCD display circuit.

Wiring Diagram for the load cell circuit

Code

The code for the first Argon, i.e. the one with the load cell sensor and RGB LED is shown below.

C/C++
This is coding done on particle.build.
// This #include statement was automatically added by the Particle IDE.
#include <HX711.h>

#define DOUT  0
#define CLK  2
HX711 scale(DOUT, CLK);
float temperature;

void LED(const char *event, const char *data)
{
    String pew = data;
    temperature = pew.toFloat();
}
 float calibration_factor = 535; // this calibration factor is adjusted according to my load cell
float units;
float units1;

void setup() {
    int ledB=D6;
    int ledG=D7;
    int ledR=D8;

pinMode(ledB,OUTPUT);
pinMode(ledG,OUTPUT);
pinMode(ledR,OUTPUT);


 Serial.begin(9600);  
 Serial.println("Press T to tare");
scale.set_scale(calibration_factor); //Adjust to this calibration factor
 scale.tare(); 
}



void loop() {
units = scale.get_units(), 5;
 if (units < 0)
 {
   units = 0.00;
 }

 units1 = (units/29.57);
 
 
    Particle.publish("Ounces", String(units1),PUBLIC);  //subscribe to this mouse event.
    delay(1000);  //delay to prevent overloading the cloud communication.
   Particle.subscribe("LED_David",LED);
   if (temperature<1.1) {
            digitalWrite(D6,HIGH);
            digitalWrite(D7,LOW);
       digitalWrite(D8,LOW);
   }
 else if (temperature<2.1){
  digitalWrite(D6,LOW);
       digitalWrite(D7,HIGH);
            digitalWrite(D8,LOW);
  }
  else {
           digitalWrite(D6,LOW);
                digitalWrite(D7,LOW);
      digitalWrite(D8,HIGH);
  }


 
 if(Serial.available())
 {
   char temp = Serial.read();
   if(temp == 't' || temp == 'T')
     scale.tare();  //Reset the scale to zero      
 }
} 

The code for the second Argon, i.e. the one with the LCD display is shown below.

C/C++
This is coding done on particle.build.
// This #include statement was automatically added by the Particle IDE.
#include <LiquidCrystal.h>


LiquidCrystal lcd(6, 1, 5, 4, 3, 7);


float temperature;
void temper(const char *event, const char *data )
{
    String pew = data;
    temperature = pew.toFloat();
}


void setup() {
        Particle.subscribe("Ounces", temper);
  // set up the LCD's number of columns and rows: 
  lcd.begin(16,2);
  Serial.begin(9600);
    lcd.print("Ounces:");
}


void loop(){
  // Print a message to the LCD.

  delay(1000);
  lcd.setCursor(8,0);
  lcd.print(temperature);
  
  if (temperature<1.49) {
      Particle.publish("LED_David",String(1),PUBLIC);
  }
  else if (temperature<1.59) {
    Particle.publish("LED_David",String(2),PUBLIC); }
else {
      Particle.publish("LED_David",String(3),PUBLIC);
}

}

Credits

David Potter

David Potter

1 project • 0 followers
Phil Brown

Phil Brown

1 project • 0 followers

Comments

Add projectSign up / Login