Friday, September 27, 2019

Week 9 - Arduino Coding Upload and Blynk Setting (Troubleshooting Week)

Belowis the coding use in arduino for the sorting and monitoring purposes:

#include <Servo.h>

Servo myservo1;  // create servo object to control a servo


#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

char auth[] = "rPCNUbMxbzdkCQ5ERfCUj-83Jj5eGouh";
char ssid[] = "Wifi_Project";
char pass[] = "1a2b3c4d5e";
#define ESP8266_BAUD 115200
ESP8266 wifi(&Serial);

#define trigPin1 2
#define echoPin1 3

#define trigPin2 4
#define echoPin2 5

int ir,metal;

long duration, distance, Sensor1,Sensor2;

void setup() {

   myservo1.attach(9);
      myservo1.write(90);
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
pinMode(A0,INPUT);
 Serial.begin(ESP8266_BAUD);
 //Serial.begin(9600);
 delay(10);
 Blynk.begin(auth, wifi, ssid, pass);

}

void loop() {
 Blynk.run();

ir = digitalRead(A0);
metal=digitalRead(A1);

SonarSensor(trigPin1, echoPin1);
Sensor1 = distance;
Serial.print("Sensor Metal: ");
Serial.println(Sensor1);

SonarSensor(trigPin2, echoPin2);
Sensor2 = distance;
Serial.print("Sensor Non Metal: ");
Serial.println(Sensor2);

Serial.print("IR: ");
Serial.println(ir);

Serial.print("Metal: ");
Serial.println(metal);

Blynk.virtualWrite(0,Sensor1);
Blynk.virtualWrite(1,Sensor2);

if(metal == 0 && ir == 1) //no object
{
    myservo1.write(90);
}

if(metal == 1 && ir == 0) //metal
{
    myservo1.write(50);
}

if(metal == 0 && ir == 0) //non metal
{
    myservo1.write(130);
}

delay(1000);

}

void SonarSensor(int trigPin,int echoPin)
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;

}

The project is success even though the servo motor is a bit loose and needed to be glue.


Lastly is the blynk apps display, the project will not move if not linked to the apps/wifi.


Monday, September 16, 2019

Week 8 - Circuit, wiring installation, software arduino coding upload and syncing with Blynk

On this week, most of critical part is done, first is installing the servo motor to the body as in picture below:


after that the wiring continues until the sensor and arduino is attached with the body until it became as below picture but it is not fully attach as I only use double sided in case of troubleshooting:




Friday, September 6, 2019

Week 7 - Fabricated the project body with external parties

As from the previous week, the project body is sent for fabrication during semester break.It is made at furniture store as the body of this prototype is made from wood. The measurement should be, 40W x 36D x 42H. Below is the drawing of the project body:

By the end of week the project fabricated is done and wiring is also done, below are the picture of the body: