Software apps and online services | ||||||
| ||||||
| ||||||
Hand tools and fabrication machines | ||||||
|
This coffee delivery robot is powered by the Alexa. The robot path is pre-coded and we can tell Alexa to go which table based on the user requirement, the voice command will help the robot to decide which path to take and which table to reach based on the code.
We can also ask coffeebot to release the gripper so that user can take the coffee.
This could be also be used as a personal assistant and makes a great smart home robot.
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"
#include<Servo.h>
Servo servo;
#define WIFI_SSID "Vampire"//change your Wifi name
#define WIFI_PASS "dragonfire@"//Change your Wifi Password
#define SERIAL_BAUDRATE 115200
fauxmoESP fauxmo;
//declare switching pins
//Change pins according to your NodeMCU pinouts
#define EnA D1
#define In1 D2
#define In2 D3
#define EnB D5
#define In3 D6
#define In4 D7
#define Grip D4
const int motorspeed=200;
// -----------------------------------------------------------------------------
// Wifi Setup
// -----------------------------------------------------------------------------
/*void turnLeft()
{
analogWrite(EnA,motorspeed);
digitalWrite(In1,LOW);
digitalWrite(In2,HIGH);
digitalWrite(In3,LOW);
digitalWrite(In4,LOW);
delay(5000);
}
void turnRight()
{
analogWrite(EnB,motorspeed);
digitalWrite(In1,LOW);
digitalWrite(In2,LOW);
digitalWrite(In3,LOW);
digitalWrite(In4,HIGH);
delay(5000);
}
*/
void wifiSetup() {
// Set WIFI module to STA mode
WiFi.mode(WIFI_STA);
// Connect
Serial.printf("[WIFI] Connecting to %s ", WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);
// Wait
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(100);
}
Serial.println();
// Connected!
Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
}
// -----------------------------------------------------------------------------
// Device Callback
// -----------------------------------------------------------------------------
void callback(uint8_t device_id, const char * device_name, bool state) {
Serial.print("Device "); Serial.print(device_name);
Serial.print(" state: ");
if (state) {
Serial.println("ON");
} else {
Serial.println("OFF");
}
//Switching action on detection of device name
if ( (strcmp(device_name, "Coffee Service") == 0) ) {
if (state) {
analogWrite(EnA,0);
analogWrite(EnB,0);
digitalWrite(In1,LOW);
digitalWrite(In2,LOW);
digitalWrite(In3,LOW);
digitalWrite(In4,LOW);
}
}
else {
analogWrite(EnA,0);
analogWrite(EnB,0);
digitalWrite(In1,LOW);
digitalWrite(In2,HIGH);
digitalWrite(In3,LOW);
digitalWrite(In4,HIGH);
}
if ( (strcmp(device_name, "Coffee Holder") == 0) ) {
if (state) {
for(int i=105;i>50;i--)
{
servo.write(i); //d1
delay(10);
}
} else {
for(int i=25;i<105;i++)
{
servo.write(i); //d1
delay(10);
}
}
}
// if ( (strcmp(device_name, "Bedroom Lights") == 0) ) {
// // adjust the relay immediately!
// if (state) {
// digitalWrite(Bedroom, HIGH);
// } else {
// digitalWrite(Bedroom, LOW);
// }
// }
// if ( (strcmp(device_name, "Living Room Lights") == 0) ) {
// // adjust the relay immediately!
// if (state) {
// digitalWrite(Living, HIGH);
// } else {
// digitalWrite(Living, LOW);
// }
}
void setup() {
//Initialize pins to Low on device start
pinMode(EnA, OUTPUT);
// digitalWrite(EnA, LOW);
pinMode(In2, OUTPUT);
//digitalWrite(In2, LOW);
pinMode(In1, OUTPUT);
//digitalWrite(In1, LOW);
servo.attach(Grip);
pinMode(EnB, OUTPUT);
//digitalWrite(EnB, LOW);
pinMode(In3, OUTPUT);
//digitalWrite(In3, LOW);
pinMode(In4, OUTPUT);
//digitalWrite(In4, LOW);
// Init serial port and clean garbage
Serial.begin(SERIAL_BAUDRATE);
Serial.println("FauxMo demo sketch");
Serial.println("After connection, ask Alexa/Echo to 'turn <devicename> on' or 'off'");
// Wifi
wifiSetup();
// Device Names for Simulated Wemo switches
fauxmo.addDevice("Coffee Holder");
fauxmo.addDevice("Coffee Service");
fauxmo.addDevice("Bedroom Lights");
fauxmo.onMessage(callback);
}
void loop() {
fauxmo.handle();
// analogWrite(EnA,motorspeed);
// analogWrite(EnB,motorspeed);
// digitalWrite(In1,LOW);
// digitalWrite(In2,HIGH);
// digitalWrite(In3,LOW);
// digitalWrite(In4,HIGH);
// delay(500);
}
John Baptist Rodrigues
1 project • 17 followers
I am John Rodrigues,Mechanical Design Engineer by profession| blogger and writer at designwithjohn.com
Comments