SlideShare a Scribd company logo
/ GENESIS BOARD MINI SUMO ROBOT PROGRAM
//FOR 3 OPPONENT SENSOR, 2 EDGE SENSOR
// JSUMO 01/2020
///////////////////////////////////////
//MOTOR CONTROL
int RPwm = 11;
int RDir = 13;
int LPwm = 3;
int LDir = 12;
//LED & BUZZER
int Buzzer = 9;
int ArduLed = 8;
//EDGE & CONTRAST SENSORS
int Redge = A0;
int Ledge = A1;
//TRIMPOTS
int SPD = A7;
int TRN = A6;
//OPPONENT SENSORS
int LSens = A4;
int RSens = A2;
int MSens = A3;
int LFSens = A5;
int RFSens = 4;
// DIPSWITCH & BUTTON
int Button = 10; // Can be used as start pin too.
int DS1 = 5;
int DS2 = 6;
int DS3 = 7;
//VALUES
int Speed =50;
int MaxSpeed = 80; // Idle Speed while no sensor giving data.
int TurnSpeed = 65; // Left and Right Forward Turning Speed
int EdgeTurn = 150; // Turning Time variable when minisumo sees white line
int Duration; // Turning Time at minisumo starting.
int LastValue = 5; // Last Value Variable for remembering last Opponent sensor sense.
void setup()
{
pinMode(LSens, INPUT); // Left Opponent Sensor Input
pinMode(RSens, INPUT); // Right Opponent Sensor Input
pinMode(MSens, INPUT); // Middle Opponent Sensor Input
pinMode(Buzzer, OUTPUT); // Buzzer Declared as Output
pinMode(ArduLed, OUTPUT); // Buzzer Declared as Output
pinMode(Button, INPUT); // Buzzer Declared as Output
pinMode(RPwm, OUTPUT); // Four PWM Channel Declared as Output
pinMode(RDir, OUTPUT);
pinMode(LPwm, OUTPUT);
pinMode(LDir, OUTPUT);
digitalWrite(Buzzer, LOW); // Buzzer Pin Made Low for Silence
digitalWrite(ArduLed, LOW); // Arduino Mode Led Made Low
digitalWrite(DS1, HIGH); // 3 Dipswitch Pin Pullups Made
digitalWrite(DS2, HIGH);
digitalWrite(DS3, HIGH);
digitalWrite(LSens, HIGH); // Opponent Sensor Pullups Made
digitalWrite(RSens, HIGH);
digitalWrite(LFSens, HIGH);
digitalWrite(RFSens, HIGH);
digitalWrite(MSens, HIGH);
Serial.begin(9600);
}
//Motor Control Function
void Set_Motor (float Lval, float Rval, int timex){
Lval = Lval*2.5;
Rval = Rval*2.5;
if (Lval >=0) {
analogWrite(LPwm, Lval);
digitalWrite(LDir, LOW);
} else {
Lval=abs(Lval);
digitalWrite(LDir, HIGH);
analogWrite(LPwm, Lval);
}
if (Rval >=0) {
analogWrite(RPwm, Rval);
digitalWrite(RDir, HIGH);
} else {
Rval=abs(Rval);
digitalWrite(RDir, LOW);
analogWrite(RPwm, Rval);
}
//If you want to see Speed Values please uncomment bottom line.
// Serial.print(Rval); Serial.print(-); Serial.println(Lval);
delay(timex);
}
void loop() {
digitalWrite(RPwm, LOW);
digitalWrite(LPwm, LOW);
tone(Buzzer, 18, 100); // Pin, Frequency, Duration
//////////////////////////////////////////////
// This function below, used for stopping robot while no button is pushed or Microstart is not
triggered.
while (digitalRead(Button)==0) {
Serial.println(Button Press Waited);
Set_Motor(0,0,1);
/// Sensor Control While Waiting The Button Press ///
if ( digitalRead(MSens)==LOW || digitalRead(RSens)==LOW || digitalRead(LSens)== LOW ||
digitalRead(RFSens)==LOW || digitalRead(LFSens)== LOW || analogRead(Redge)< 100 ||
analogRead(Ledge)< 100 ) { digitalWrite(ArduLed, HIGH);}
else { digitalWrite(ArduLed, LOW); }
}
///////////////////////////////////////////////
if (digitalRead(Button)==1) {
Duration=(analogRead(TRN)/5); // Duration variable based on TRN (A6) trimpot
Duration=205-Duration; //
Serial.println(5 Sec Routine Started);
for (int i = 0; i < 5; i++){ digitalWrite(Buzzer, HIGH); digitalWrite(ArduLed, HIGH);
delay(100); digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, LOW); delay(900); }
if (digitalRead(DS1)==0 && digitalRead(DS2)==1 && digitalRead(DS3)==1){
Serial.print(LEFT TURN);
Set_Motor(-100,100,Duration); //
}
else if (digitalRead(DS1)==0 && digitalRead(DS2)==0 && digitalRead(DS3)==0) {
Serial.print(MIDDLE DIRECT);
Set_Motor(80,80,2);
}
else if (digitalRead(DS1)==1 && digitalRead(DS2)==1 && digitalRead(DS3)==0){
Serial.print(Sag);
Set_Motor(100,-100,Duration);
}
else if (digitalRead(DS1)==1 && digitalRead(DS2)==0 && digitalRead(DS3)==0){
Serial.print(Left Circle);
Set_Motor(100,36,650);
}
else if (digitalRead(DS1)==0 && digitalRead(DS2)==0 && digitalRead(DS3)==1){
Serial.print(Right Circle);
Set_Motor(36,100,650);
}
else if (digitalRead(DS1)==0 && digitalRead(DS2)==1 && digitalRead(DS3)==0){
Serial.print(Reverse 180);
Set_Motor(-100,100,Duration*2); // One Duration time is for 90 degree, so we multiply by 2.
}
Serial.print(OK);
digitalWrite(Buzzer, LOW);
EdgeTurn=(analogRead(TRN)/5); // Raw value comes with 0 to 1023, we divide it for 0 t0 205
mS turning time.
EdgeTurn=205-EdgeTurn; //
}
//Main Loop
while(1) {
/// Edge Sensor Control Routine ///
digitalWrite(ArduLed, LOW);
if (analogRead(Ledge)<300 && analogRead(Redge)> 300) {
digitalWrite(Buzzer, LOW);
digitalWrite(ArduLed, HIGH);
Set_Motor(-100, -100,55); // Backward for 55 mS.
Set_Motor(-100, 100, EdgeTurn); // Left Backward, Right Forward, Turning Time Based on
ETRN Trimpot
LastValue=5;
}
else if (analogRead(Ledge)> 300 && analogRead(Redge)< 300) {
digitalWrite(Buzzer, LOW);
digitalWrite(ArduLed, HIGH);
Set_Motor(-100, -100,55); // Backward for 55 mS.
Set_Motor(100, -100, EdgeTurn); // Right Backward, Left Forward, Turning Time Based on
ETRN Trimpot
LastValue=5;
}
else if (analogRead(Ledge)< 300 && analogRead(Redge)< 300) {
digitalWrite(Buzzer, LOW);
digitalWrite(ArduLed, HIGH);
Set_Motor(-100, -100,55); // Backward for 55 mS.
Set_Motor(100, -100, EdgeTurn); // Right Backward, Left Forward, Turning Time Based on
ETRN Trimpot
LastValue=5;
}else
/// Opponent Sensor Control Routine ///
// Please uncomment below line if yu are using microstart, When microstart gives 0V it will stop
motors.
//while (digitalRead(Button)==LOW) {Set_Motor(0, 0, 20); digitalWrite(Buzzer, HIGH);
LastValue=3;} digitalWrite(Buzzer, LOW);
if (digitalRead(MSens)==LOW) {Set_Motor(MaxSpeed, MaxSpeed,1); digitalWrite(Buzzer,
HIGH); LastValue=5;} else
if (digitalRead(LSens)== LOW) {Set_Motor(-40, TurnSpeed,1); digitalWrite(Buzzer, HIGH);
LastValue=7;} else
if (digitalRead(RSens)==LOW) {Set_Motor(TurnSpeed, -40,1); digitalWrite(Buzzer, HIGH);
LastValue=3;} else
if (digitalRead(LFSens)== LOW) {Set_Motor(-40, TurnSpeed,1); digitalWrite(Buzzer, HIGH);
LastValue=7;} else
if (digitalRead(RFSens)==LOW) {Set_Motor(TurnSpeed, -40,1); digitalWrite(Buzzer, HIGH);
LastValue=3;} else
{
digitalWrite(Buzzer, LOW);
Speed=(analogRead(SPD)/10.3); // This raw speed value comes with 0 to 1023 so we divide to
10.3 After that it is 0 to 99 integer.
Speed=100-Speed; // This is used for reversing trimpot dial direction at board.
if (LastValue==5) { Set_Motor(Speed, Speed,1);} else // Forward, Based on SPD (A7) Trimpot
if (LastValue==7) { Set_Motor(-20, Speed,2);} else // Left Turning Based on SPD (A7) Trimpot
if (LastValue==3) { Set_Motor(Speed, -20,2);} // Right Turning Based on SPD (A7) Trimpot
}
}
}
Can you integrate the above code according to the items written below?
Now program your robot to follow a square shaped path, as follows:
i. Go forward for one second,
ii. Make a 90 degree left turn,
iii. Go to step (i).
iv. Stop after four turns.
/ GENESIS BOARD MINI SUMO ROBOT PROGRAM
//FOR 3 OPPONENT SENSOR, 2 EDGE SENSOR
// JSUMO 01/2020
///////////////////////////////////////
//MOTOR CONTROL
int RPwm = 11;
int RDir = 13;
int LPwm = 3;
int LDir = 12;
//LED & BUZZER
int Buzzer = 9;
int ArduLed = 8;
//EDGE & CONTRAST SENSORS
int Redge = A0;
int Ledge = A1;
//TRIMPOTS
int SPD = A7;
int TRN = A6;
//OPPONENT SENSORS
int LSens = A4;
int RSens = A2;
int MSens = A3;
int LFSens = A5;
int RFSens = 4;
// DIPSWITCH & BUTTON
int Button = 10; // Can be used as start pin too.
int DS1 = 5;
int DS2 = 6;
int DS3 = 7;
//VALUES
int Speed =50;
int MaxSpeed = 80; // Idle Speed while no sensor giving data.
int TurnSpeed = 65; // Left and Right Forward Turning Speed
int EdgeTurn = 150; // Turning Time variable when minisumo sees white line
int Duration; // Turning Time at minisumo starting.
int LastValue = 5; // Last Value Variable for remembering last Opponent sensor sense.
void setup()
{
pinMode(LSens, INPUT); // Left Opponent Sensor Input
pinMode(RSens, INPUT); // Right Opponent Sensor Input
pinMode(MSens, INPUT); // Middle Opponent Sensor Input
pinMode(Buzzer, OUTPUT); // Buzzer Declared as Output
pinMode(ArduLed, OUTPUT); // Buzzer Declared as Output
pinMode(Button, INPUT); // Buzzer Declared as Output
pinMode(RPwm, OUTPUT); // Four PWM Channel Declared as Output
pinMode(RDir, OUTPUT);
pinMode(LPwm, OUTPUT);
pinMode(LDir, OUTPUT);
digitalWrite(Buzzer, LOW); // Buzzer Pin Made Low for Silence
digitalWrite(ArduLed, LOW); // Arduino Mode Led Made Low
digitalWrite(DS1, HIGH); // 3 Dipswitch Pin Pullups Made
digitalWrite(DS2, HIGH);
digitalWrite(DS3, HIGH);
digitalWrite(LSens, HIGH); // Opponent Sensor Pullups Made
digitalWrite(RSens, HIGH);
digitalWrite(LFSens, HIGH);
digitalWrite(RFSens, HIGH);
digitalWrite(MSens, HIGH);
Serial.begin(9600);
}
//Motor Control Function
void Set_Motor (float Lval, float Rval, int timex){
Lval = Lval*2.5;
Rval = Rval*2.5;
if (Lval >=0) {
analogWrite(LPwm, Lval);
digitalWrite(LDir, LOW);
} else {
Lval=abs(Lval);
digitalWrite(LDir, HIGH);
analogWrite(LPwm, Lval);
}
if (Rval >=0) {
analogWrite(RPwm, Rval);
digitalWrite(RDir, HIGH);
} else {
Rval=abs(Rval);
digitalWrite(RDir, LOW);
analogWrite(RPwm, Rval);
}
//If you want to see Speed Values please uncomment bottom line.
// Serial.print(Rval); Serial.print(-); Serial.println(Lval);
delay(timex);
}
void loop() {
digitalWrite(RPwm, LOW);
digitalWrite(LPwm, LOW);
tone(Buzzer, 18, 100); // Pin, Frequency, Duration
//////////////////////////////////////////////
// This function below, used for stopping robot while no button is pushed or Microstart is not
triggered.
while (digitalRead(Button)==0) {
Serial.println(Button Press Waited);
Set_Motor(0,0,1);
/// Sensor Control While Waiting The Button Press ///
if ( digitalRead(MSens)==LOW || digitalRead(RSens)==LOW || digitalRead(LSens)== LOW ||
digitalRead(RFSens)==LOW || digitalRead(LFSens)== LOW || analogRead(Redge)< 100 ||
analogRead(Ledge)< 100 ) { digitalWrite(ArduLed, HIGH);}
else { digitalWrite(ArduLed, LOW); }
}
///////////////////////////////////////////////
if (digitalRead(Button)==1) {
Duration=(analogRead(TRN)/5); // Duration variable based on TRN (A6) trimpot
Duration=205-Duration; //
Serial.println(5 Sec Routine Started);
for (int i = 0; i < 5; i++){ digitalWrite(Buzzer, HIGH); digitalWrite(ArduLed, HIGH);
delay(100); digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, LOW); delay(900); }
if (digitalRead(DS1)==0 && digitalRead(DS2)==1 && digitalRead(DS3)==1){
Serial.print(LEFT TURN);
Set_Motor(-100,100,Duration); //
}
else if (digitalRead(DS1)==0 && digitalRead(DS2)==0 && digitalRead(DS3)==0) {
Serial.print(MIDDLE DIRECT);
Set_Motor(80,80,2);
}
else if (digitalRead(DS1)==1 && digitalRead(DS2)==1 && digitalRead(DS3)==0){
Serial.print(Sag);
Set_Motor(100,-100,Duration);
}
else if (digitalRead(DS1)==1 && digitalRead(DS2)==0 && digitalRead(DS3)==0){
Serial.print(Left Circle);
Set_Motor(100,36,650);
}
else if (digitalRead(DS1)==0 && digitalRead(DS2)==0 && digitalRead(DS3)==1){
Serial.print(Right Circle);
Set_Motor(36,100,650);
}
else if (digitalRead(DS1)==0 && digitalRead(DS2)==1 && digitalRead(DS3)==0){
Serial.print(Reverse 180);
Set_Motor(-100,100,Duration*2); // One Duration time is for 90 degree, so we multiply by 2.
}
Serial.print(OK);
digitalWrite(Buzzer, LOW);
EdgeTurn=(analogRead(TRN)/5); // Raw value comes with 0 to 1023, we divide it for 0 t0 205
mS turning time.
EdgeTurn=205-EdgeTurn; //
}
//Main Loop
while(1) {
/// Edge Sensor Control Routine ///
digitalWrite(ArduLed, LOW);
if (analogRead(Ledge)<300 && analogRead(Redge)> 300) {
digitalWrite(Buzzer, LOW);
digitalWrite(ArduLed, HIGH);
Set_Motor(-100, -100,55); // Backward for 55 mS.
Set_Motor(-100, 100, EdgeTurn); // Left Backward, Right Forward, Turning Time Based on
ETRN Trimpot
LastValue=5;
}
else if (analogRead(Ledge)> 300 && analogRead(Redge)< 300) {
digitalWrite(Buzzer, LOW);
digitalWrite(ArduLed, HIGH);
Set_Motor(-100, -100,55); // Backward for 55 mS.
Set_Motor(100, -100, EdgeTurn); // Right Backward, Left Forward, Turning Time Based on
ETRN Trimpot
LastValue=5;
}
else if (analogRead(Ledge)< 300 && analogRead(Redge)< 300) {
digitalWrite(Buzzer, LOW);
digitalWrite(ArduLed, HIGH);
Set_Motor(-100, -100,55); // Backward for 55 mS.
Set_Motor(100, -100, EdgeTurn); // Right Backward, Left Forward, Turning Time Based on
ETRN Trimpot
LastValue=5;
}else
/// Opponent Sensor Control Routine ///
// Please uncomment below line if yu are using microstart, When microstart gives 0V it will stop
motors.
//while (digitalRead(Button)==LOW) {Set_Motor(0, 0, 20); digitalWrite(Buzzer, HIGH);
LastValue=3;} digitalWrite(Buzzer, LOW);
if (digitalRead(MSens)==LOW) {Set_Motor(MaxSpeed, MaxSpeed,1); digitalWrite(Buzzer,
HIGH); LastValue=5;} else
if (digitalRead(LSens)== LOW) {Set_Motor(-40, TurnSpeed,1); digitalWrite(Buzzer, HIGH);
LastValue=7;} else
if (digitalRead(RSens)==LOW) {Set_Motor(TurnSpeed, -40,1); digitalWrite(Buzzer, HIGH);
LastValue=3;} else
if (digitalRead(LFSens)== LOW) {Set_Motor(-40, TurnSpeed,1); digitalWrite(Buzzer, HIGH);
LastValue=7;} else
if (digitalRead(RFSens)==LOW) {Set_Motor(TurnSpeed, -40,1); digitalWrite(Buzzer, HIGH);
LastValue=3;} else
{
digitalWrite(Buzzer, LOW);
Speed=(analogRead(SPD)/10.3); // This raw speed value comes with 0 to 1023 so we divide to
10.3 After that it is 0 to 99 integer.
Speed=100-Speed; // This is used for reversing trimpot dial direction at board.
if (LastValue==5) { Set_Motor(Speed, Speed,1);} else // Forward, Based on SPD (A7) Trimpot
if (LastValue==7) { Set_Motor(-20, Speed,2);} else // Left Turning Based on SPD (A7) Trimpot
if (LastValue==3) { Set_Motor(Speed, -20,2);} // Right Turning Based on SPD (A7) Trimpot
}
}
}
Can you integrate the above code according to the items written below?
Now program your robot to follow a square shaped path, as follows:
i. Go forward for one second,
ii. Make a 90 degree left turn,
iii. Go to step (i).
iv. Stop after four turns.
Now program your robot to follow a square shaped path, as follows:
i. Go forward for one second,
ii. Make a 90 degree left turn,
iii. Go to step (i).
iv. Stop after four turns.

More Related Content

DOC
FINISHED_CODE
PPT
Arduinomotorcontrolusingservoultrasonic
DOCX
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
PDF
What will be quantization step size in numbers and in voltage for th.pdf
PDF
Musical Machines and Flapping Phones
PPTX
Computer networks unit III CHAPTER of frameworks
PDF
Arduino uno basic Experiments for beginner
TXT
Metal detecting robot sketch
FINISHED_CODE
Arduinomotorcontrolusingservoultrasonic
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
What will be quantization step size in numbers and in voltage for th.pdf
Musical Machines and Flapping Phones
Computer networks unit III CHAPTER of frameworks
Arduino uno basic Experiments for beginner
Metal detecting robot sketch

Similar to GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf (20)

PDF
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
PDF
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
DOCX
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22
DOCX
Ldr based line follower robot
KEY
Scottish Ruby Conference 2010 Arduino, Ruby RAD
PDF
PROGRAMMING ADC and DAC-mbed.pdf
PPTX
Arduino Programming
PDF
MaxBotix Code Examples
PPTX
INTRODUCTION TO ARDUINO and sensors for arduino.pptx
PPT
Hexapod ppt
KEY
Sbaw090908
PDF
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
PDF
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
DOCX
Arduino Final Project
PPT
01 Intro to the Arduino and it's basics.ppt
DOCX
IOT excercise ESP32 Simulation projects.docx
PPTX
online technology POWERPOINT PRESENTATION
PDF
Mdp plus 2.1
PPTX
Arduino cic3
PDF
Arduino: Analog I/O
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22
Ldr based line follower robot
Scottish Ruby Conference 2010 Arduino, Ruby RAD
PROGRAMMING ADC and DAC-mbed.pdf
Arduino Programming
MaxBotix Code Examples
INTRODUCTION TO ARDUINO and sensors for arduino.pptx
Hexapod ppt
Sbaw090908
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
Arduino Final Project
01 Intro to the Arduino and it's basics.ppt
IOT excercise ESP32 Simulation projects.docx
online technology POWERPOINT PRESENTATION
Mdp plus 2.1
Arduino cic3
Arduino: Analog I/O
Ad

More from alltiusind (20)

PDF
Given a doubly-linked list (2,3,4,5,6,7), node 2 s pointer(s) point(.pdf
PDF
Given a list, remove item with index 0,4,5 from list if there exist a.pdf
PDF
Georgia Kennel uses tenant-days as its measure of activity; an animal.pdf
PDF
Georgia Kennel uses tenant-days as its measure of activity; an anmal .pdf
PDF
George Morton, gerente del departamento de mantenimiento de un gr.pdf
PDF
Get an educations A sucvey asked 32,114 people how much confidence th.pdf
PDF
General Instructions - Submit your solution no later than 1159pm ET .pdf
PDF
Generate and upload a PDA in JFF format for the following grammar Hi.pdf
PDF
General exceptions to.pdf
PDF
Gator Investments provides financial services related to investment s.pdf
PDF
Gotthelf Clinic uses client-visits as its measure of activity. During.pdf
PDF
Gopton Company Is considering a capptal bodgeting froject that would .pdf
PDF
Gordon Millers job shop has four work areas, A, B, C, and D. Distanc.pdf
PDF
Given the following relation staff property staffinspection Express.pdf
PDF
Globalization and Tourism Development - western values, authenticity,.pdf
PDF
Give you two list, return True if they have common item, False if the.pdf
PDF
Glycolaldehyde inhibits the Calvin cycle by inhibiting RuBP. What Cal.pdf
PDF
Glucans are small pieces of the cell walls of molds that may cause .pdf
PDF
Give Me Your Money bank knows they get on average 18 calls per hour o.pdf
PDF
Given the following BNF (1) Rewrite the above BNF to reflect the fol.pdf
Given a doubly-linked list (2,3,4,5,6,7), node 2 s pointer(s) point(.pdf
Given a list, remove item with index 0,4,5 from list if there exist a.pdf
Georgia Kennel uses tenant-days as its measure of activity; an animal.pdf
Georgia Kennel uses tenant-days as its measure of activity; an anmal .pdf
George Morton, gerente del departamento de mantenimiento de un gr.pdf
Get an educations A sucvey asked 32,114 people how much confidence th.pdf
General Instructions - Submit your solution no later than 1159pm ET .pdf
Generate and upload a PDA in JFF format for the following grammar Hi.pdf
General exceptions to.pdf
Gator Investments provides financial services related to investment s.pdf
Gotthelf Clinic uses client-visits as its measure of activity. During.pdf
Gopton Company Is considering a capptal bodgeting froject that would .pdf
Gordon Millers job shop has four work areas, A, B, C, and D. Distanc.pdf
Given the following relation staff property staffinspection Express.pdf
Globalization and Tourism Development - western values, authenticity,.pdf
Give you two list, return True if they have common item, False if the.pdf
Glycolaldehyde inhibits the Calvin cycle by inhibiting RuBP. What Cal.pdf
Glucans are small pieces of the cell walls of molds that may cause .pdf
Give Me Your Money bank knows they get on average 18 calls per hour o.pdf
Given the following BNF (1) Rewrite the above BNF to reflect the fol.pdf
Ad

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Complications of Minimal Access Surgery at WLH
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
master seminar digital applications in india
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
Microbial diseases, their pathogenesis and prophylaxis
Module 4: Burden of Disease Tutorial Slides S2 2025
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Cell Structure & Organelles in detailed.
Complications of Minimal Access Surgery at WLH
Microbial disease of the cardiovascular and lymphatic systems
Pharma ospi slides which help in ospi learning
Final Presentation General Medicine 03-08-2024.pptx
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
master seminar digital applications in india
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O5-L3 Freight Transport Ops (International) V1.pdf
Anesthesia in Laparoscopic Surgery in India

GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf

  • 1. / GENESIS BOARD MINI SUMO ROBOT PROGRAM //FOR 3 OPPONENT SENSOR, 2 EDGE SENSOR // JSUMO 01/2020 /////////////////////////////////////// //MOTOR CONTROL int RPwm = 11; int RDir = 13; int LPwm = 3; int LDir = 12; //LED & BUZZER int Buzzer = 9; int ArduLed = 8; //EDGE & CONTRAST SENSORS int Redge = A0; int Ledge = A1; //TRIMPOTS int SPD = A7; int TRN = A6; //OPPONENT SENSORS int LSens = A4; int RSens = A2; int MSens = A3;
  • 2. int LFSens = A5; int RFSens = 4; // DIPSWITCH & BUTTON int Button = 10; // Can be used as start pin too. int DS1 = 5; int DS2 = 6; int DS3 = 7; //VALUES int Speed =50; int MaxSpeed = 80; // Idle Speed while no sensor giving data. int TurnSpeed = 65; // Left and Right Forward Turning Speed int EdgeTurn = 150; // Turning Time variable when minisumo sees white line int Duration; // Turning Time at minisumo starting. int LastValue = 5; // Last Value Variable for remembering last Opponent sensor sense. void setup() { pinMode(LSens, INPUT); // Left Opponent Sensor Input pinMode(RSens, INPUT); // Right Opponent Sensor Input pinMode(MSens, INPUT); // Middle Opponent Sensor Input pinMode(Buzzer, OUTPUT); // Buzzer Declared as Output pinMode(ArduLed, OUTPUT); // Buzzer Declared as Output pinMode(Button, INPUT); // Buzzer Declared as Output pinMode(RPwm, OUTPUT); // Four PWM Channel Declared as Output pinMode(RDir, OUTPUT);
  • 3. pinMode(LPwm, OUTPUT); pinMode(LDir, OUTPUT); digitalWrite(Buzzer, LOW); // Buzzer Pin Made Low for Silence digitalWrite(ArduLed, LOW); // Arduino Mode Led Made Low digitalWrite(DS1, HIGH); // 3 Dipswitch Pin Pullups Made digitalWrite(DS2, HIGH); digitalWrite(DS3, HIGH); digitalWrite(LSens, HIGH); // Opponent Sensor Pullups Made digitalWrite(RSens, HIGH); digitalWrite(LFSens, HIGH); digitalWrite(RFSens, HIGH); digitalWrite(MSens, HIGH); Serial.begin(9600); } //Motor Control Function void Set_Motor (float Lval, float Rval, int timex){ Lval = Lval*2.5; Rval = Rval*2.5; if (Lval >=0) { analogWrite(LPwm, Lval); digitalWrite(LDir, LOW); } else { Lval=abs(Lval); digitalWrite(LDir, HIGH); analogWrite(LPwm, Lval); } if (Rval >=0) { analogWrite(RPwm, Rval); digitalWrite(RDir, HIGH); } else {
  • 4. Rval=abs(Rval); digitalWrite(RDir, LOW); analogWrite(RPwm, Rval); } //If you want to see Speed Values please uncomment bottom line. // Serial.print(Rval); Serial.print(-); Serial.println(Lval); delay(timex); } void loop() { digitalWrite(RPwm, LOW); digitalWrite(LPwm, LOW); tone(Buzzer, 18, 100); // Pin, Frequency, Duration ////////////////////////////////////////////// // This function below, used for stopping robot while no button is pushed or Microstart is not triggered. while (digitalRead(Button)==0) { Serial.println(Button Press Waited); Set_Motor(0,0,1); /// Sensor Control While Waiting The Button Press /// if ( digitalRead(MSens)==LOW || digitalRead(RSens)==LOW || digitalRead(LSens)== LOW || digitalRead(RFSens)==LOW || digitalRead(LFSens)== LOW || analogRead(Redge)< 100 || analogRead(Ledge)< 100 ) { digitalWrite(ArduLed, HIGH);} else { digitalWrite(ArduLed, LOW); } } /////////////////////////////////////////////// if (digitalRead(Button)==1) { Duration=(analogRead(TRN)/5); // Duration variable based on TRN (A6) trimpot Duration=205-Duration; // Serial.println(5 Sec Routine Started); for (int i = 0; i < 5; i++){ digitalWrite(Buzzer, HIGH); digitalWrite(ArduLed, HIGH);
  • 5. delay(100); digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, LOW); delay(900); } if (digitalRead(DS1)==0 && digitalRead(DS2)==1 && digitalRead(DS3)==1){ Serial.print(LEFT TURN); Set_Motor(-100,100,Duration); // } else if (digitalRead(DS1)==0 && digitalRead(DS2)==0 && digitalRead(DS3)==0) { Serial.print(MIDDLE DIRECT); Set_Motor(80,80,2); } else if (digitalRead(DS1)==1 && digitalRead(DS2)==1 && digitalRead(DS3)==0){ Serial.print(Sag); Set_Motor(100,-100,Duration); } else if (digitalRead(DS1)==1 && digitalRead(DS2)==0 && digitalRead(DS3)==0){ Serial.print(Left Circle); Set_Motor(100,36,650); } else if (digitalRead(DS1)==0 && digitalRead(DS2)==0 && digitalRead(DS3)==1){ Serial.print(Right Circle); Set_Motor(36,100,650); } else if (digitalRead(DS1)==0 && digitalRead(DS2)==1 && digitalRead(DS3)==0){ Serial.print(Reverse 180); Set_Motor(-100,100,Duration*2); // One Duration time is for 90 degree, so we multiply by 2. } Serial.print(OK); digitalWrite(Buzzer, LOW); EdgeTurn=(analogRead(TRN)/5); // Raw value comes with 0 to 1023, we divide it for 0 t0 205 mS turning time. EdgeTurn=205-EdgeTurn; // }
  • 6. //Main Loop while(1) { /// Edge Sensor Control Routine /// digitalWrite(ArduLed, LOW); if (analogRead(Ledge)<300 && analogRead(Redge)> 300) { digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, HIGH); Set_Motor(-100, -100,55); // Backward for 55 mS. Set_Motor(-100, 100, EdgeTurn); // Left Backward, Right Forward, Turning Time Based on ETRN Trimpot LastValue=5; } else if (analogRead(Ledge)> 300 && analogRead(Redge)< 300) { digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, HIGH); Set_Motor(-100, -100,55); // Backward for 55 mS. Set_Motor(100, -100, EdgeTurn); // Right Backward, Left Forward, Turning Time Based on ETRN Trimpot LastValue=5; } else if (analogRead(Ledge)< 300 && analogRead(Redge)< 300) { digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, HIGH); Set_Motor(-100, -100,55); // Backward for 55 mS. Set_Motor(100, -100, EdgeTurn); // Right Backward, Left Forward, Turning Time Based on ETRN Trimpot LastValue=5; }else /// Opponent Sensor Control Routine /// // Please uncomment below line if yu are using microstart, When microstart gives 0V it will stop motors. //while (digitalRead(Button)==LOW) {Set_Motor(0, 0, 20); digitalWrite(Buzzer, HIGH); LastValue=3;} digitalWrite(Buzzer, LOW);
  • 7. if (digitalRead(MSens)==LOW) {Set_Motor(MaxSpeed, MaxSpeed,1); digitalWrite(Buzzer, HIGH); LastValue=5;} else if (digitalRead(LSens)== LOW) {Set_Motor(-40, TurnSpeed,1); digitalWrite(Buzzer, HIGH); LastValue=7;} else if (digitalRead(RSens)==LOW) {Set_Motor(TurnSpeed, -40,1); digitalWrite(Buzzer, HIGH); LastValue=3;} else if (digitalRead(LFSens)== LOW) {Set_Motor(-40, TurnSpeed,1); digitalWrite(Buzzer, HIGH); LastValue=7;} else if (digitalRead(RFSens)==LOW) {Set_Motor(TurnSpeed, -40,1); digitalWrite(Buzzer, HIGH); LastValue=3;} else { digitalWrite(Buzzer, LOW); Speed=(analogRead(SPD)/10.3); // This raw speed value comes with 0 to 1023 so we divide to 10.3 After that it is 0 to 99 integer. Speed=100-Speed; // This is used for reversing trimpot dial direction at board. if (LastValue==5) { Set_Motor(Speed, Speed,1);} else // Forward, Based on SPD (A7) Trimpot if (LastValue==7) { Set_Motor(-20, Speed,2);} else // Left Turning Based on SPD (A7) Trimpot if (LastValue==3) { Set_Motor(Speed, -20,2);} // Right Turning Based on SPD (A7) Trimpot } } } Can you integrate the above code according to the items written below? Now program your robot to follow a square shaped path, as follows: i. Go forward for one second, ii. Make a 90 degree left turn, iii. Go to step (i). iv. Stop after four turns.
  • 8. / GENESIS BOARD MINI SUMO ROBOT PROGRAM //FOR 3 OPPONENT SENSOR, 2 EDGE SENSOR // JSUMO 01/2020 /////////////////////////////////////// //MOTOR CONTROL int RPwm = 11; int RDir = 13; int LPwm = 3; int LDir = 12; //LED & BUZZER int Buzzer = 9; int ArduLed = 8; //EDGE & CONTRAST SENSORS int Redge = A0; int Ledge = A1; //TRIMPOTS int SPD = A7; int TRN = A6; //OPPONENT SENSORS int LSens = A4; int RSens = A2; int MSens = A3;
  • 9. int LFSens = A5; int RFSens = 4; // DIPSWITCH & BUTTON int Button = 10; // Can be used as start pin too. int DS1 = 5; int DS2 = 6; int DS3 = 7; //VALUES int Speed =50; int MaxSpeed = 80; // Idle Speed while no sensor giving data. int TurnSpeed = 65; // Left and Right Forward Turning Speed int EdgeTurn = 150; // Turning Time variable when minisumo sees white line int Duration; // Turning Time at minisumo starting. int LastValue = 5; // Last Value Variable for remembering last Opponent sensor sense. void setup() { pinMode(LSens, INPUT); // Left Opponent Sensor Input pinMode(RSens, INPUT); // Right Opponent Sensor Input pinMode(MSens, INPUT); // Middle Opponent Sensor Input pinMode(Buzzer, OUTPUT); // Buzzer Declared as Output pinMode(ArduLed, OUTPUT); // Buzzer Declared as Output pinMode(Button, INPUT); // Buzzer Declared as Output pinMode(RPwm, OUTPUT); // Four PWM Channel Declared as Output pinMode(RDir, OUTPUT); pinMode(LPwm, OUTPUT); pinMode(LDir, OUTPUT);
  • 10. digitalWrite(Buzzer, LOW); // Buzzer Pin Made Low for Silence digitalWrite(ArduLed, LOW); // Arduino Mode Led Made Low digitalWrite(DS1, HIGH); // 3 Dipswitch Pin Pullups Made digitalWrite(DS2, HIGH); digitalWrite(DS3, HIGH); digitalWrite(LSens, HIGH); // Opponent Sensor Pullups Made digitalWrite(RSens, HIGH); digitalWrite(LFSens, HIGH); digitalWrite(RFSens, HIGH); digitalWrite(MSens, HIGH); Serial.begin(9600); } //Motor Control Function void Set_Motor (float Lval, float Rval, int timex){ Lval = Lval*2.5; Rval = Rval*2.5; if (Lval >=0) { analogWrite(LPwm, Lval); digitalWrite(LDir, LOW); } else { Lval=abs(Lval); digitalWrite(LDir, HIGH); analogWrite(LPwm, Lval); } if (Rval >=0) { analogWrite(RPwm, Rval); digitalWrite(RDir, HIGH); } else { Rval=abs(Rval); digitalWrite(RDir, LOW);
  • 11. analogWrite(RPwm, Rval); } //If you want to see Speed Values please uncomment bottom line. // Serial.print(Rval); Serial.print(-); Serial.println(Lval); delay(timex); } void loop() { digitalWrite(RPwm, LOW); digitalWrite(LPwm, LOW); tone(Buzzer, 18, 100); // Pin, Frequency, Duration ////////////////////////////////////////////// // This function below, used for stopping robot while no button is pushed or Microstart is not triggered. while (digitalRead(Button)==0) { Serial.println(Button Press Waited); Set_Motor(0,0,1); /// Sensor Control While Waiting The Button Press /// if ( digitalRead(MSens)==LOW || digitalRead(RSens)==LOW || digitalRead(LSens)== LOW || digitalRead(RFSens)==LOW || digitalRead(LFSens)== LOW || analogRead(Redge)< 100 || analogRead(Ledge)< 100 ) { digitalWrite(ArduLed, HIGH);} else { digitalWrite(ArduLed, LOW); } } /////////////////////////////////////////////// if (digitalRead(Button)==1) { Duration=(analogRead(TRN)/5); // Duration variable based on TRN (A6) trimpot Duration=205-Duration; // Serial.println(5 Sec Routine Started); for (int i = 0; i < 5; i++){ digitalWrite(Buzzer, HIGH); digitalWrite(ArduLed, HIGH); delay(100); digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, LOW); delay(900); }
  • 12. if (digitalRead(DS1)==0 && digitalRead(DS2)==1 && digitalRead(DS3)==1){ Serial.print(LEFT TURN); Set_Motor(-100,100,Duration); // } else if (digitalRead(DS1)==0 && digitalRead(DS2)==0 && digitalRead(DS3)==0) { Serial.print(MIDDLE DIRECT); Set_Motor(80,80,2); } else if (digitalRead(DS1)==1 && digitalRead(DS2)==1 && digitalRead(DS3)==0){ Serial.print(Sag); Set_Motor(100,-100,Duration); } else if (digitalRead(DS1)==1 && digitalRead(DS2)==0 && digitalRead(DS3)==0){ Serial.print(Left Circle); Set_Motor(100,36,650); } else if (digitalRead(DS1)==0 && digitalRead(DS2)==0 && digitalRead(DS3)==1){ Serial.print(Right Circle); Set_Motor(36,100,650); } else if (digitalRead(DS1)==0 && digitalRead(DS2)==1 && digitalRead(DS3)==0){ Serial.print(Reverse 180); Set_Motor(-100,100,Duration*2); // One Duration time is for 90 degree, so we multiply by 2. } Serial.print(OK); digitalWrite(Buzzer, LOW); EdgeTurn=(analogRead(TRN)/5); // Raw value comes with 0 to 1023, we divide it for 0 t0 205 mS turning time. EdgeTurn=205-EdgeTurn; // } //Main Loop
  • 13. while(1) { /// Edge Sensor Control Routine /// digitalWrite(ArduLed, LOW); if (analogRead(Ledge)<300 && analogRead(Redge)> 300) { digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, HIGH); Set_Motor(-100, -100,55); // Backward for 55 mS. Set_Motor(-100, 100, EdgeTurn); // Left Backward, Right Forward, Turning Time Based on ETRN Trimpot LastValue=5; } else if (analogRead(Ledge)> 300 && analogRead(Redge)< 300) { digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, HIGH); Set_Motor(-100, -100,55); // Backward for 55 mS. Set_Motor(100, -100, EdgeTurn); // Right Backward, Left Forward, Turning Time Based on ETRN Trimpot LastValue=5; } else if (analogRead(Ledge)< 300 && analogRead(Redge)< 300) { digitalWrite(Buzzer, LOW); digitalWrite(ArduLed, HIGH); Set_Motor(-100, -100,55); // Backward for 55 mS. Set_Motor(100, -100, EdgeTurn); // Right Backward, Left Forward, Turning Time Based on ETRN Trimpot LastValue=5; }else /// Opponent Sensor Control Routine /// // Please uncomment below line if yu are using microstart, When microstart gives 0V it will stop motors. //while (digitalRead(Button)==LOW) {Set_Motor(0, 0, 20); digitalWrite(Buzzer, HIGH); LastValue=3;} digitalWrite(Buzzer, LOW); if (digitalRead(MSens)==LOW) {Set_Motor(MaxSpeed, MaxSpeed,1); digitalWrite(Buzzer, HIGH); LastValue=5;} else
  • 14. if (digitalRead(LSens)== LOW) {Set_Motor(-40, TurnSpeed,1); digitalWrite(Buzzer, HIGH); LastValue=7;} else if (digitalRead(RSens)==LOW) {Set_Motor(TurnSpeed, -40,1); digitalWrite(Buzzer, HIGH); LastValue=3;} else if (digitalRead(LFSens)== LOW) {Set_Motor(-40, TurnSpeed,1); digitalWrite(Buzzer, HIGH); LastValue=7;} else if (digitalRead(RFSens)==LOW) {Set_Motor(TurnSpeed, -40,1); digitalWrite(Buzzer, HIGH); LastValue=3;} else { digitalWrite(Buzzer, LOW); Speed=(analogRead(SPD)/10.3); // This raw speed value comes with 0 to 1023 so we divide to 10.3 After that it is 0 to 99 integer. Speed=100-Speed; // This is used for reversing trimpot dial direction at board. if (LastValue==5) { Set_Motor(Speed, Speed,1);} else // Forward, Based on SPD (A7) Trimpot if (LastValue==7) { Set_Motor(-20, Speed,2);} else // Left Turning Based on SPD (A7) Trimpot if (LastValue==3) { Set_Motor(Speed, -20,2);} // Right Turning Based on SPD (A7) Trimpot } } } Can you integrate the above code according to the items written below? Now program your robot to follow a square shaped path, as follows: i. Go forward for one second, ii. Make a 90 degree left turn, iii. Go to step (i). iv. Stop after four turns. Now program your robot to follow a square shaped path, as follows: i. Go forward for one second,
  • 15. ii. Make a 90 degree left turn, iii. Go to step (i). iv. Stop after four turns.