0% found this document useful (0 votes)
30 views

Mutuacode

This document contains code for controlling a vegetable cutting machine. It initializes a LCD display and pins for motors, sensors and output devices. The main loop prints status messages, checks sensors for obstacles on the conveyor belt or errors detected. If product 1 is detected, it runs the conveyor, activates the slap and gong mechanisms to cut. If product 2, it does the same with slightly different timing. If an error is detected, it reverses the conveyor and shows an error message.

Uploaded by

Berhe
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Mutuacode

This document contains code for controlling a vegetable cutting machine. It initializes a LCD display and pins for motors, sensors and output devices. The main loop prints status messages, checks sensors for obstacles on the conveyor belt or errors detected. If product 1 is detected, it runs the conveyor, activates the slap and gong mechanisms to cut. If product 2, it does the same with slightly different timing. If an error is detected, it reverses the conveyor and shows an error message.

Uploaded by

Berhe
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include<LiquidCrystal.

h>

LiquidCrystal lcd(27,26, 22,23, 24, 25);

//L293D for pin 37, 38

const int motorPin1 = 37;

const int motorPin2 = 38;

int convmotor=28;

int IRsensor=29;

int Logicstatep1 = 30;// sensors 30 is a dummy sensors for simulating signal sent from the ML model i.e
Product1 or Product2

int Logicstatee2 = 31;// sensors 31 is a dummy sensors used to mimic an error signal sent by the
ML,Setting logic state HIGH for an error.

int hasobstacle = HIGH;

int hasobstacle1 = HIGH;

int hasobstacle2 = HIGH;

int slap1=33;

int slap2=34;

int gong=35;

int LED=36;

void setup()

lcd.begin(16,2);

pinMode(convmotor,OUTPUT);

pinMode(IRsensor,INPUT);

pinMode(Logicstatep1,INPUT);

pinMode(Logicstatee2,INPUT);
pinMode(slap1,OUTPUT);

pinMode(slap2,OUTPUT);

pinMode(gong,OUTPUT);

pinMode(LED,OUTPUT);

pinMode(motorPin1,OUTPUT);

pinMode(motorPin2,OUTPUT);

void loop()

lcd.setCursor(0,0);

lcd.print("VEGETABLE CUTTER");

lcd.setCursor(1,2);

lcd.print("Ben Mos Pac");

hasobstacle = digitalRead(IRsensor);

if (hasobstacle == LOW)

digitalWrite(motorPin1,HIGH);

lcd.clear();

lcd.print("CONVEYOR ON");

delay(2000);

digitalWrite(motorPin1,LOW);

lcd.clear();

lcd.print("CONVEYOR OFF");

lcd.setCursor(1,2);

lcd.print("LOGIC STATE");

hasobstacle1 = digitalRead(Logicstatep1);// we are reading for the Logicstatep1


if (hasobstacle1 == LOW)// This is for product 1

digitalWrite(motorPin1,HIGH);

lcd.clear();

lcd.print("CONVEYOR ON");

delay(3000);

digitalWrite(slap1,HIGH);// Here we are knocking off the veg to cutter

delay(500); //assume that this is time enough to set an impact knock on the veg

digitalWrite(slap1,LOW);

delay(100);//

digitalWrite(gong,HIGH);// Setting the gong cutter on to cut the veg

lcd.setCursor(1,2);

lcd.print("CTIN PRDCT1");

delay(2000);// Assume that this is the time for two stroke

else (hasobstacle1==HIGH);// This is for product 2

digitalWrite(motorPin1,HIGH);

delay(4300);

lcd.clear();

lcd.print("CONVEYOR ON");

digitalWrite(slap2,HIGH);// Here we are knocking off the veg to cutter 2

delay(500);// assume that this is time enough to set an impact knock on the veg

digitalWrite(slap1,LOW);

delay(100);

digitalWrite(gong,HIGH);

lcd.setCursor(1,2);
lcd.print("CTIN PRDCT2");

delay(2000); // Assume that this is the time for two strokes

hasobstacle2 = digitalRead(Logicstatee2);// reading logicstatee2

if (hasobstacle2 == HIGH)/// this is only going to simulate the error idea

digitalWrite(LED,HIGH);

delay(3000);

lcd.clear();

lcd.print("UNKNOWN PRODUCT");

digitalWrite(motorPin2,HIGH);// conveyor set to reverse

delay(2000);

else

delay(100);

// lcd.print("ML RECOGNIZING");// We are mimi..ing this nby using irsensors

else

digitalWrite(motorPin1,LOW);

lcd.clear();

lcd.print("CONVEYOR OFF");
}

delay(5000);

You might also like