This is my first project ever.
I wanted to combine my passion to programming and electronics and Arduino seems like a perfect tool for that
I would like to make a drinks dispenser that will pour liquid using a peristaltic pump to 5 different glasses (I would like to use a Servo to turn the arm of the device).
On top of that I would like it to have a bluetooth connection so I could connect a Android device and write an app that does all the logic behind the device functioning. The Arduino sketch would only have a couple of commands to set servo to different positions and turn the pump on/off.
My main concerns are:
connecting everything the right way.
Please could you help me and take a look at the schematic attached (thanks Fritzing!) that i made myself, so it may be really bad, but please, don't judge
I don't know if the power supply is sufficient to run arduino, pump, servo and the bluetooth module. I assume that servo and the pump will never run simultaneously.
Do I need to use logic level converter to use with HC-05/06 module? I have seen people do it without those.
Is the transistor and diode even a good idea to connect the 12V pump to Arduino? Should I rather use a step-up converter?
Also below you can find the sketch that I would like to use:
/*
Different available data values sent by bluetooth using Android app:
data = 1Â //turn the pump on
data = 2Â // turn the pump off
data = 3Â // turn servo to position 1
data = 4Â // turn servo to position 2
data = 5Â // turn servo to position 3
data = 6Â // turn servo to position 4
data = 7Â // turn servo to position 5
*/
#include <Servo.h>
Servo myservo;
const int pump = 9; // pump pin number
const int ser = 8; // servo pin number
const int pos1 = 1;
const int pos2 = 2;
const int pos3 = 3;
const int pos4 = 4;
const int pos5 = 5;
char data = 0;
void setup() {
  Serial.begin(9600);
  pinMode(pump, OUTPUT);
  myservo.attach(ser);
}
void loop() {
 if(Serial.available())
 {
  data = Serial.read();
  Serial.print(data);
  Serial.print("\n");
  if(data==1){
   digitalWrite(pump,HIGH);
  }
  if(data==2){
   digitalWrite(pump,LOW);
  }
  if(data==3){
   myservo.write(pos1);
  }
  if(data==4){
   myservo.write(pos2);
  }
  if(data==5){
   myservo.write(pos3);
  }
  if(data==6){
   myservo.write(pos4);
  }
  if(data==7){
   myservo.write(pos5);
  }
 }
}
All the parts are being shipped to me, so I can't test it right now.
I have seen people use bluetoothSerial.begin(), but Arduino IDE sends out an error while I test it.
You should power the servo directly from the USB charger rather than through the Arduino. The Arduino 5v pin cannot provide enough current for motors.
Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.
The technique in the 3rd example will be the most reliable. It is what I use for Arduino to Arduino and Arduino to PC communication.
You can send data in a compatible format with code like this (or the equivalent in any other programming language)
If you connect the Bluetooth device to Pins 0 and 1 (Rx and Tx) you will need to disconnect it when uploading programs. You will probably find it easier to use SoftwareSerial to create an extra serial port on two other pins and use that (at 9600 baud) for the Bluetooth module.
I am not competent to comment on your choice of transistor.
I was afraid that you would say that about powering motors through Arduino pins
This is why I wanted to ask you guys, because I just have seen different weird stuff in the Internet.
Could I then use 12V power supply to power the Pump and then use a step down converter to get 5V to power the servo and Arduino?
And then use Arduino pins to control relays that would turn the pump servo on/off?
Thanks about the SoftwareSerial tip!
Will dig deeper in the link you've recommended, thank you
ginlegucki:
Could I then use 12V power supply to power the Pump and then use a step down converter to get 5V to power the servo and Arduino?
Yes, that sounds like a good idea
And then use Arduino pins to control relays that would turn the pump servo on/off?
A electromechanical relay will generally need more current for its coil than an Arduino I/O pin can provide. However you can buy relay modules that can be directly connected to an Arduino - in effect they take a separate 5v power supply for the coils and have the necessary transistor circuits to allow the Arduino to switch the current in the coils.
By the way I did not mean to imply that your idea of using a transistor rather than a relay is wrong. For your project it may be simpler - I just don't know enough to advise about the choice of transistor.
"I would like to make a drinks dispenser that will pour liquid using a peristaltic pump to 5 different glasses"
Use the forum search feature to search for project key words like "bartender" and you will probably find previous discussions on the same type projects.