Anda di halaman 1dari 11

SOALAN 1

Cadangkan 1 projek menggunakan arduino, di mana projek ini perlu sekurang-kurangnya 3


peralatan input & 3 peralatan output.

Tajuk Projek: Mesin Pengasingan Tomato

Penerangan Projek:

<Letak Fungsi Projek>

1 Mesin ini dapat mengasingkan buah tomato berdasarkan warna buah tersebut.
2 Mesin ini juga dapat mengasingkan buah tomato mengikut skala berat yang telah
ditetapkan.
3 Mesin ini dapat beroperasi secara automatik dan dikendalikan oleh seorang pekerja
sahaja.

<Objektif Projek>

Terdapat beberapa objektif yang ingin dicapai dalam pelaksanaan mesin pengasingan
tomato ini antaranya:
1. Mengasingkan tomato yang masak dan kurang masak mengikut warna yang telah
ditetapkan.
2. Mengasingkan tomato yang dipetik berdasarkan julat berat yang telah ditetapkan.
3. Membangunkan mesin pengasingan tomato secara automatik

(10 Marks)

Input & Output Assignment.

INPUT DEVICE

PORT DEVICE FUNCTION

Pin 8 RGB Color Sensor To detect the colour of tomatoes

Pin 16 Weighing Load Cell To identify the weight of tomato

1
Pin 3 Start Button To start the machine

OUTPUT DEVICE

PORT DEVICE FUNCTION

Pin 9 Servo motor 360° Use as part feeder to make sure tomato
is checked one by one

Pin 10 Servo motor 180° Use as stopper to stop the tomato at the
checking position

Pin 11 Servo motor 180° Use as a gate to make sure tomato go to


the right slider

(10 Marks)

a. Electrical Wiring Diagram.

[ATTACH ELECTRICAL WIRING DIAGRAM HERE]

(10 Marks)

b. Coding Arduino Sketch beserta penerangan.

[PROGRAM CODING]

#include <Arduino.h>

#include <Wire.h>

2
#include <SoftwareSerial.h>

#include <HX711.h>

#include <Servo.h>

Servo myservo;

Servo servo_10;

Servo servo_11;

Servo servo_12;

Servo servo_13;

//define load cell

#define DOUT 16

#define CLK 17

HX711 scale(DOUT, CLK);

float calibration_factor = -993600.00; //-910800.00 worked for 1kg max

int Reading = 0;

//define untuk colour sensor

#define S0 4

#define S1 5

#define S2 6

#define S3 7

#define sensorOut 8

int greenColor = 0;

/* ******************************************************************** */

void setup() {

3
// put your setup code here, to run once:

// Begins serial communication

Serial.begin(9600);

// setting load cell

scale.set_scale();

scale.tare(); //Reset the scale to 0

Serial.print("Reading: ");

Serial.print(scale.get_units(), 3);

Serial.print(" kg");

Serial.println(" ");

//long zero_factor = calibration_factor;

long zero_factor = scale.read_average(); //Get a baseline reading

Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale.
Useful in permanent scale projects.

Serial.println(zero_factor);

//untuk servo motor

servo_10.attach(10); // init pin

servo_11.attach(11); // init pin

servo_12.attach(12); // init pin

servo_13.attach(13); // init pin

myservo.attach(9);

// semua bawah ni untuk colour sensor

//Setting the outputs

4
pinMode(S0, OUTPUT);

pinMode(S1, OUTPUT);

pinMode(S2, OUTPUT);

pinMode(S3, OUTPUT);

// Setting the sensorOut as an input

pinMode(sensorOut, INPUT);

// Setting frequency scaling to 20%

digitalWrite(S0,HIGH);

digitalWrite(S1,HIGH);

/* ******************************************************************** */

void loop() {

// put your main code here, to run repeatedly:

PartFeeder();

Color();

LoadCell();

delay(500);

Sensor();

Calibrate();

void Sensor(){

if (scale.get_units() >= 0.010){

if(( greenColor < 64) && (0.010 <= (scale.get_units() <= 0.080)))

5
{//HIJAU RINGAN

Pintu();

Gate2();}

else if(( greenColor >= 64) && (0.010 <= (scale.get_units() >= 0.081)))

{//MERAH BERAT

Pintu();

Gate1();}

else if(( greenColor < 64) && (0.010 <= (scale.get_units() >= 0.081)))

{//HIJAU BERAT

Pintu();

Gate4();}

else if(( greenColor >= 64) && (0.010 <= (scale.get_units() <= 0.080)))

{//MERAH RINGAN

Pintu();

Gate3();}}

else{

Serial.print("****EMPTY****");

Serial.println(" ");

Serial.println(" ");

servo_10.write(0); // write to servo

delay(1000);

PartFeeder();

6
}

void PartFeeder()

{ servo_10.write(0);

myservo.write(99);

delay(2550);

myservo.write(90);

delay(100);

servo_10.write(0);

delay(100);// write to servo}

void Pintu()

{servo_10.write(0); // write to servo

delay(1000);

//servo_10.write(75); // write to servo

//delay(1000);}

void Gate1()

{Serial.println(" - RED BERAT!!! ");

Serial.print("MASUK 1");

Serial.println(" ");

Serial.println(" ");

servo_11.write(75); // write to servo

delay(1000);

7
servo_10.write(75);

delay(3000);

Pintu();

PartFeeder();}

void Gate2()

{Serial.println(" - GREEN RINGAN!!! ");

Serial.print("MASUK 2");

Serial.println(" ");

Serial.println(" ");

servo_12.write(90); // write to servo

servo_11.write(0); // write to servo

delay(1000);

servo_10.write(75);

delay(5000);

Pintu();

PartFeeder();}

void Gate3()

Serial.println(" - RED RINGAN!!! ");

Serial.print("MASUK 3");

Serial.println(" ");

Serial.println(" ");

8
servo_13.write(75); // write to servo

servo_11.write(0); // write to servo

servo_12.write(0); // write to servo

delay(1000);

servo_10.write(75);

delay(7000);

Pintu();

PartFeeder();

void Gate4()

Serial.println(" - GREEN BERAT!!! ");

Serial.print("MASUK 4");

Serial.println(" ");

Serial.println(" ");

servo_11.write(0); // write to servo

servo_12.write(0); // write to servo

servo_13.write(0); // write to servo

servo_10.write(0); // write to servo

9
delay(1000);

servo_10.write(75);

delay(9000);

Pintu();

PartFeeder();

void Color()

{ // Setting green filtered photodiodes to be read

digitalWrite(S2,HIGH);

digitalWrite(S3,HIGH);

// Reading the output frequency

greenColor = pulseIn(sensorOut, LOW);

Serial.print("GREEN= ");//printing name

Serial.print(greenColor);//printing GREEN color frequency

Serial.println(" ");

delay(500);}

void LoadCell()

{scale.set_scale(calibration_factor);

10
Serial.print("Calibration Factor");

Serial.print(calibration_factor);

Serial.println(" ");

Serial.print("Reading: ");

Serial.print(scale.get_units(), 3);

Serial.print(" kg");

Serial.println(" ");

delay(500);}

(20 Marks)

[PENERANGAN PROGRAM]

Apabila start button ditekan, mesin akan mula beroperasi. Part feeder akan berpusing dan
membenarkan hanya sebiji buah tomato untuk turun ke bahagian pemeriksaan warna dan
berat. Seterusnya colour sensor dan load cell akan menilai warna dan berat buat. Stopper
akan terbuka setelah mendapati kriteria buah tomato yang telah diperiksa. Konveyor akan
membawa buah tersebut dan buah tomato masuk ke bahagian pengasingan yang telah
ditetapkan.

11

Anda mungkin juga menyukai