#include
Servo myservo;
#include
#include
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x3F, 20, 4);
int mt1p1 = 25;// Blue - 28BYJ48 pin 1
int mt1p2 = 24;// Pink - 28BYJ48 pin 2
int mt1p3 = 23;// Yellow - 28BYJ48 pin 3
int mt1p4 = 22;// Orange - 28BYJ48 pin 4
//----------------------------------------------
int mt2p1 = 49;// Blue - 28BYJ48 pin 1
int mt2p2 = 48;// Pink - 28BYJ48 pin 2
int mt2p3 = 47;// Yellow - 28BYJ48 pin 3
int mt2p4 = 46;// Orange - 28BYJ48 pin 4
//----------------------------------------------
int mt3p1 = 34;// Blue - 28BYJ48 pin 1
int mt3p2 = 35;// Pink - 28BYJ48 pin 2
int mt3p3 = 36;// Yellow - 28BYJ48 pin 3
int mt3p4 = 37;// Orange - 28BYJ48 pin 4
//-----------------------------------------------
int mt4p1 = 42;// Blue - 28BYJ48 pin 1
int mt4p2 = 43;// Pink - 28BYJ48 pin 2
int mt4p3 = 44;// Yellow - 28BYJ48 pin 3
int mt4p4 = 45;// Orange - 28BYJ48 pin 4
//-----------------------------------------------
int motorSpeed = 1; //variable to set stepper speed
int TL_motorSpeed = 1;
//*************************************************************
// สำหรับ Donger_step1
// ..... เลี้ยวหลบ ...........////---------
int DGL1= 450; // หมุ่นเลี้ยว ซ้าย1
int DGFF1= 500; // ตรง1
int DGR1= 450; // หมุ่นเลี้ยว ขวา1
int DGFFF1= 1200; // ตรง2
int DGRR1= 450; // หมุ่นเลี้ยว ขวา2
int DGFFFF1= 500; // ตรง3
int DGLL1= 450; // หมุ่นเลี้ยว ซ้าย2
//*************************************************************
// สำหรับ Change_lenses1
//____เปลี่ยนเลน_1__////
int CLR1 = 420;// หมุ่นเลี้ยว ขวา1
int CLF1 = 600;// ตรง1
int CLRR1 = 420; // หมุ่นเลี้ยว ขวา1
//*************************************************************
// สำหรับ Change_lenses2
//____เปลี่ยนเลน_1__////
int CLR2 = 420; // หมุ่นเลี้ยว ขวา1
int CLF2 = 600; // ตรง1
int CLRR2 = 430; // หมุ่นเลี้ยว ขวา1
//************************************************************
// สำหรับ Donger_step2
// ..... เลี้ยวหลบ ......2.....////---------
int DGR2 = 460; // หมุ่นเลี้ยว ขวา1
int DGF2 = 500; // ตรง1
int DGRR2 = 460; // หมุ่นเลี้ยว ขวา1
int DGFF2 = 1200; // ตรง2
int DGRRR2 = 460; // หมุ่นเลี้ยว ขวา2
int DGFFF2 = 500; // ตรง3
int DGL2 = 460; // หมุ่นเลี้ยว ซ้าย2
//////////////////////////////////////////////////////////////////////////////
int i = 0;
bool is1 = false , is2 = false ,is3 = false ,is4 = false;
bool Dodge1 = false , Dodge2 = false;
bool lenses1 = false , lenses2 = false;
bool cm_dis = false;
int Sw1 = 32;
int Sw2 = 33;
int S1, S2;
int counter_F, counter_F2;
int counterNum = 1, counterNum2 = 1;
//****servo*****
//****untra****************
const int pingPin = 7;
int inPin = 6;
long duration, cm, cm_Value, Distant = 10;
int counter, counter2 = 0;
///*****LCD******************
int X1 = 440;
int g = 0;
int b = 0;
int c = 0;//วิ่งรอบแรก
int a = 0;//วิ่งรอบ2
void setup() {
char Mapp[20][4] = {
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
};
//declare the motor pins as outputs
lcd.begin ();
myservo.attach(3);
myservo.write(0);
lcd.setCursor(0, 0);
lcd.print("D");
Mapp[0][0] = 'D';
lcd.setCursor(2, 0);
lcd.print("E");
Mapp[2][0] = 'E';
lcd.setCursor(4,0);
lcd.print("L");
Mapp[4][0] = 'L';
lcd.setCursor(6,0);
lcd.print("M");
Mapp[6][0] = 'M';
lcd.setCursor(8, 0);
lcd.print("d");
Mapp[8][0] = 'd';
lcd.setCursor(10, 0);
lcd.print("e");
Mapp[10][0] = 'e';
lcd.setCursor(12,0);
lcd.print("l");
Mapp[12][0] = 'l';
lcd.setCursor(14,0);
lcd.print("m");
Mapp[14][0] = 'm';
lcd.setCursor(0, 1);
lcd.print("C");
Mapp[0][1] = 'C';
lcd.setCursor(2, 1);
lcd.print("F");
Mapp[2][1] = 'F';
lcd.setCursor(4,1);
lcd.print("K");
Mapp[4][1] = 'K';
lcd.setCursor(6,1);
lcd.print("N");
Mapp[6][1] = 'N';
lcd.setCursor(8, 1);
lcd.print("c");
Mapp[8][1] ='c';
lcd.setCursor(10, 1);
lcd.print("f");
Mapp[10][1] = 'f';
lcd.setCursor(12,1);
lcd.print("k");
Mapp[12][1] = 'k';
lcd.setCursor(14,1);
lcd.print("n");
Mapp[14][1] = 'n';
lcd.setCursor(0, 2);
lcd.print("B");
Mapp[0][2] = 'B';
lcd.setCursor(2, 2);
lcd.print("G");
Mapp[2][2] = 'G';
lcd.setCursor(4,2);
lcd.print("J");
Mapp[4][2] = 'J';
lcd.setCursor(6,2);
lcd.print("O");
Mapp[6][2] = 'O';
lcd.setCursor(8, 2);
lcd.print("b");
Mapp[8][2] ='b';
lcd.setCursor(10, 2);
lcd.print("g");
Mapp[10][2] = 'g';
lcd.setCursor(12,2);
lcd.print("j");
Mapp[12][2] = 'j';
lcd.setCursor(14,2);
lcd.print("o");
Mapp[14][2] = 'o';
lcd.setCursor(0, 3);
lcd.print("A");
Mapp[0][3] = 'A';
lcd.setCursor(2, 3);
lcd.print("H");
Mapp[2][3] = 'H';
lcd.setCursor(4,3);
lcd.print("I");
Mapp[4][3] = 'I';
lcd.setCursor(6,3);
lcd.print("P");
Mapp[6][3] = 'P';
lcd.setCursor(8, 3);
lcd.print("a");
Mapp[8][3] = 'a';
lcd.setCursor(10, 3);
lcd.print("h");
Mapp[10][3] = 'h';
lcd.setCursor(12,3);
lcd.print("i");
Mapp[12][3] = 'i';
lcd.setCursor(14,3);
lcd.print("p");
Mapp[14][3] = 'p';
pinMode(Sw1, INPUT);
pinMode(Sw2, INPUT);
pinMode(mt1p1, OUTPUT);
pinMode(mt1p2, OUTPUT);
pinMode(mt1p3, OUTPUT);
pinMode(mt1p4, OUTPUT);
pinMode(mt2p1, OUTPUT);
pinMode(mt2p2, OUTPUT);
pinMode(mt2p3, OUTPUT);
pinMode(mt2p4, OUTPUT);
pinMode(mt3p1, OUTPUT);
pinMode(mt3p2, OUTPUT);
pinMode(mt3p3, OUTPUT);
pinMode(mt3p4, OUTPUT);
pinMode(mt4p1, OUTPUT);
pinMode(mt4p2, OUTPUT);
pinMode(mt4p3, OUTPUT);
pinMode(mt4p4, OUTPUT);
Serial.begin(9600);
}
//////////////////////////////////////////////////////////////////////////////
/* counterNum = กำหนด การ เช็ค sensor เพื่อกำหนดระยะวิ่ง
counter_F = ตัวแปลนับค่า step การวิ่ง
counter = จำนวนครั้ง ในเเต่ละครั้งของการเช็ค
cm = sensor จับวัตถุ
*/
void loop() {
sensor();
if (S1 == LOW) {
is1 = true;
}
if(g == 0){
gg();
}
// if (b == 0){
// bb();
// if (a == 1){
// aa();
// }
}
void aa() {
if (Mapp[0][3] != 'X')
{
FF();
}
}
error
C:\Users\HP\Desktop\edit code project\test\test.ino: In function 'void aa()':
test:296:8: error: 'Mapp' was not declared in this scope
if (Mapp[0][3] != 'X')
^
Using library Servo at version 1.1.3 in folder: C:\Program Files (x86)\Arduino\libraries\Servo
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Using library LiquidCrystal_I2C in folder: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal_I2C (legacy)
exit status 1
'Mapp' was not declared in this scope
ช่วยแก้คำสั่ง Arduino ให้ทีครับ [1.8.3]
Servo myservo;
#include
#include
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x3F, 20, 4);
int mt1p1 = 25;// Blue - 28BYJ48 pin 1
int mt1p2 = 24;// Pink - 28BYJ48 pin 2
int mt1p3 = 23;// Yellow - 28BYJ48 pin 3
int mt1p4 = 22;// Orange - 28BYJ48 pin 4
//----------------------------------------------
int mt2p1 = 49;// Blue - 28BYJ48 pin 1
int mt2p2 = 48;// Pink - 28BYJ48 pin 2
int mt2p3 = 47;// Yellow - 28BYJ48 pin 3
int mt2p4 = 46;// Orange - 28BYJ48 pin 4
//----------------------------------------------
int mt3p1 = 34;// Blue - 28BYJ48 pin 1
int mt3p2 = 35;// Pink - 28BYJ48 pin 2
int mt3p3 = 36;// Yellow - 28BYJ48 pin 3
int mt3p4 = 37;// Orange - 28BYJ48 pin 4
//-----------------------------------------------
int mt4p1 = 42;// Blue - 28BYJ48 pin 1
int mt4p2 = 43;// Pink - 28BYJ48 pin 2
int mt4p3 = 44;// Yellow - 28BYJ48 pin 3
int mt4p4 = 45;// Orange - 28BYJ48 pin 4
//-----------------------------------------------
int motorSpeed = 1; //variable to set stepper speed
int TL_motorSpeed = 1;
//*************************************************************
// สำหรับ Donger_step1
// ..... เลี้ยวหลบ ...........////---------
int DGL1= 450; // หมุ่นเลี้ยว ซ้าย1
int DGFF1= 500; // ตรง1
int DGR1= 450; // หมุ่นเลี้ยว ขวา1
int DGFFF1= 1200; // ตรง2
int DGRR1= 450; // หมุ่นเลี้ยว ขวา2
int DGFFFF1= 500; // ตรง3
int DGLL1= 450; // หมุ่นเลี้ยว ซ้าย2
//*************************************************************
// สำหรับ Change_lenses1
//____เปลี่ยนเลน_1__////
int CLR1 = 420;// หมุ่นเลี้ยว ขวา1
int CLF1 = 600;// ตรง1
int CLRR1 = 420; // หมุ่นเลี้ยว ขวา1
//*************************************************************
// สำหรับ Change_lenses2
//____เปลี่ยนเลน_1__////
int CLR2 = 420; // หมุ่นเลี้ยว ขวา1
int CLF2 = 600; // ตรง1
int CLRR2 = 430; // หมุ่นเลี้ยว ขวา1
//************************************************************
// สำหรับ Donger_step2
// ..... เลี้ยวหลบ ......2.....////---------
int DGR2 = 460; // หมุ่นเลี้ยว ขวา1
int DGF2 = 500; // ตรง1
int DGRR2 = 460; // หมุ่นเลี้ยว ขวา1
int DGFF2 = 1200; // ตรง2
int DGRRR2 = 460; // หมุ่นเลี้ยว ขวา2
int DGFFF2 = 500; // ตรง3
int DGL2 = 460; // หมุ่นเลี้ยว ซ้าย2
//////////////////////////////////////////////////////////////////////////////
int i = 0;
bool is1 = false , is2 = false ,is3 = false ,is4 = false;
bool Dodge1 = false , Dodge2 = false;
bool lenses1 = false , lenses2 = false;
bool cm_dis = false;
int Sw1 = 32;
int Sw2 = 33;
int S1, S2;
int counter_F, counter_F2;
int counterNum = 1, counterNum2 = 1;
//****servo*****
//****untra****************
const int pingPin = 7;
int inPin = 6;
long duration, cm, cm_Value, Distant = 10;
int counter, counter2 = 0;
///*****LCD******************
int X1 = 440;
int g = 0;
int b = 0;
int c = 0;//วิ่งรอบแรก
int a = 0;//วิ่งรอบ2
void setup() {
char Mapp[20][4] = {
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
};
//declare the motor pins as outputs
lcd.begin ();
myservo.attach(3);
myservo.write(0);
lcd.setCursor(0, 0);
lcd.print("D");
Mapp[0][0] = 'D';
lcd.setCursor(2, 0);
lcd.print("E");
Mapp[2][0] = 'E';
lcd.setCursor(4,0);
lcd.print("L");
Mapp[4][0] = 'L';
lcd.setCursor(6,0);
lcd.print("M");
Mapp[6][0] = 'M';
lcd.setCursor(8, 0);
lcd.print("d");
Mapp[8][0] = 'd';
lcd.setCursor(10, 0);
lcd.print("e");
Mapp[10][0] = 'e';
lcd.setCursor(12,0);
lcd.print("l");
Mapp[12][0] = 'l';
lcd.setCursor(14,0);
lcd.print("m");
Mapp[14][0] = 'm';
lcd.setCursor(0, 1);
lcd.print("C");
Mapp[0][1] = 'C';
lcd.setCursor(2, 1);
lcd.print("F");
Mapp[2][1] = 'F';
lcd.setCursor(4,1);
lcd.print("K");
Mapp[4][1] = 'K';
lcd.setCursor(6,1);
lcd.print("N");
Mapp[6][1] = 'N';
lcd.setCursor(8, 1);
lcd.print("c");
Mapp[8][1] ='c';
lcd.setCursor(10, 1);
lcd.print("f");
Mapp[10][1] = 'f';
lcd.setCursor(12,1);
lcd.print("k");
Mapp[12][1] = 'k';
lcd.setCursor(14,1);
lcd.print("n");
Mapp[14][1] = 'n';
lcd.setCursor(0, 2);
lcd.print("B");
Mapp[0][2] = 'B';
lcd.setCursor(2, 2);
lcd.print("G");
Mapp[2][2] = 'G';
lcd.setCursor(4,2);
lcd.print("J");
Mapp[4][2] = 'J';
lcd.setCursor(6,2);
lcd.print("O");
Mapp[6][2] = 'O';
lcd.setCursor(8, 2);
lcd.print("b");
Mapp[8][2] ='b';
lcd.setCursor(10, 2);
lcd.print("g");
Mapp[10][2] = 'g';
lcd.setCursor(12,2);
lcd.print("j");
Mapp[12][2] = 'j';
lcd.setCursor(14,2);
lcd.print("o");
Mapp[14][2] = 'o';
lcd.setCursor(0, 3);
lcd.print("A");
Mapp[0][3] = 'A';
lcd.setCursor(2, 3);
lcd.print("H");
Mapp[2][3] = 'H';
lcd.setCursor(4,3);
lcd.print("I");
Mapp[4][3] = 'I';
lcd.setCursor(6,3);
lcd.print("P");
Mapp[6][3] = 'P';
lcd.setCursor(8, 3);
lcd.print("a");
Mapp[8][3] = 'a';
lcd.setCursor(10, 3);
lcd.print("h");
Mapp[10][3] = 'h';
lcd.setCursor(12,3);
lcd.print("i");
Mapp[12][3] = 'i';
lcd.setCursor(14,3);
lcd.print("p");
Mapp[14][3] = 'p';
pinMode(Sw1, INPUT);
pinMode(Sw2, INPUT);
pinMode(mt1p1, OUTPUT);
pinMode(mt1p2, OUTPUT);
pinMode(mt1p3, OUTPUT);
pinMode(mt1p4, OUTPUT);
pinMode(mt2p1, OUTPUT);
pinMode(mt2p2, OUTPUT);
pinMode(mt2p3, OUTPUT);
pinMode(mt2p4, OUTPUT);
pinMode(mt3p1, OUTPUT);
pinMode(mt3p2, OUTPUT);
pinMode(mt3p3, OUTPUT);
pinMode(mt3p4, OUTPUT);
pinMode(mt4p1, OUTPUT);
pinMode(mt4p2, OUTPUT);
pinMode(mt4p3, OUTPUT);
pinMode(mt4p4, OUTPUT);
Serial.begin(9600);
}
//////////////////////////////////////////////////////////////////////////////
/* counterNum = กำหนด การ เช็ค sensor เพื่อกำหนดระยะวิ่ง
counter_F = ตัวแปลนับค่า step การวิ่ง
counter = จำนวนครั้ง ในเเต่ละครั้งของการเช็ค
cm = sensor จับวัตถุ
*/
void loop() {
sensor();
if (S1 == LOW) {
is1 = true;
}
if(g == 0){
gg();
}
// if (b == 0){
// bb();
// if (a == 1){
// aa();
// }
}
void aa() {
if (Mapp[0][3] != 'X')
{
FF();
}
}
error
C:\Users\HP\Desktop\edit code project\test\test.ino: In function 'void aa()':
test:296:8: error: 'Mapp' was not declared in this scope
if (Mapp[0][3] != 'X')
^
Using library Servo at version 1.1.3 in folder: C:\Program Files (x86)\Arduino\libraries\Servo
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Using library LiquidCrystal_I2C in folder: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal_I2C (legacy)
exit status 1
'Mapp' was not declared in this scope