Posted on

Mini cântar Arduino și senzorul de greutate de 1kg

Mini cântar Arduino și senzorul de greutate de 1kg

mini-cantar

Arduino Code :
Atenție la fonturi dacă copiați codul

//-----------------
#include "HX711.h"
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;
HX711 scale;

#include <LiquidCrystal.h>
const int rs = A0, en = A1, d4 = A2, d5 = A3, d6 = A4, d7 = A5;
LiquidCrystal lcd(A0, A1, A2, A3, A4 ,A5);

void setup()
{
  lcd.begin(16, 2);
  Serial.begin(9600);
  delay(100);

  Serial.println("Weight ");
  Serial.println("Measuring...");
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale(2280.f);
  scale.tare();
  
  lcd.print("Insert Weight");
  delay(100);
  lcd.clear();
 }

void loop()
{
  Serial.print("one reading:\t");
  Serial.print(scale.get_units(), 1);
  Serial.print("\t| average:\t");
  Serial.println(scale.get_units(10), 1);
  scale.power_down();      
  delay(100);
  scale.power_up();

  lcd.print("Weight :");
  delay(100);
  lcd.clear();
  delay(1);
  
  lcd.print(scale.get_units());    
  lcd.print("g");
  delay(100);
  lcd.clear();
  delay(1);
}
//-----------------
Posted on

Home Automation Arduino Project – Mici automatizări acasă

Home Automation Arduino Project

Mici automatizări acasă

Componente:

Arduino UNO
Modul Bluetooth HC-05
Modul 4 relee Arduino la 5v
Fire Dupont

a1

a2

Codul:

//–––––––––––––––

String voice;

#define relay1 2 //Connect relay1 to pin 2

#define relay2 3 //Connect relay2 to pin 3

#define relay3 7 //Connect relay1 to pin 2

#define relay4 8 //Connect relay2 to pin 3

void setup()

{

Serial.begin(9600); //Set rate for communicating with phone

pinMode(relay1, OUTPUT); //Set relay1 as an output

pinMode(relay2, OUTPUT);

pinMode(relay3, OUTPUT); //Set relay2 as an output

pinMode(relay4, OUTPUT);

digitalWrite(relay1, LOW); //Switch relay1 off

digitalWrite(relay2, LOW); //Swtich relay2 off

digitalWrite(relay3, LOW); //Switch relay1 off

digitalWrite(relay4, LOW); //Swtich relay2 off

}

void loop()

{

while(Serial.available()) //Check if there are available bytes to read

{

delay(10); //Delay to make it stable

char c = Serial.read(); //Conduct a serial read

if (c == ‘#’){

break; //Stop the loop once # is detected after a word

}

voice += c; //Means voice = voice + c

}

if (voice.length() >0)

{

Serial.println(voice);

if(voice == „*switch on”){

switchon();

}

else if(voice == „*switch off”){

switchoff();

}

else if(voice == „*bulb1 on”){

digitalWrite(relay1, LOW);

}

else if(voice == „*bulb1 off”){

digitalWrite(relay1, HIGH);

}

else if(voice == „*bulb2 on”){

digitalWrite(relay2, LOW);

}

else if(voice == „*bulb2 off”){

digitalWrite(relay2, HIGH);

}

else if(voice == „*fan1 on”){

digitalWrite(relay3, LOW);

}

else if(voice == „*fan1 off”){

digitalWrite(relay3, HIGH);

}

else if(voice == „*fan2 on”){

digitalWrite(relay4, LOW);

}

else if(voice == „*fan2 off”){

digitalWrite(relay4, HIGH);

}

voice=””;

}

}

void switchon() //Function for turning on relays

{

digitalWrite(relay1, LOW);

digitalWrite(relay2, LOW);

digitalWrite(relay3, LOW);

digitalWrite(relay4, LOW);

}

void switchoff() //Function for turning on relays

{

digitalWrite(relay1, HIGH);

digitalWrite(relay2, HIGH);

digitalWrite(relay3, HIGH);

digitalWrite(relay4, HIGH);

}

//–––––––––––––––

Pentru aplicația de telefon găsiți pe Google Play multe gratis, sau o puteți face simplu urmărind tutorialele de la :

App Diagram:

https://appinventor.mit.edu/

Succes!