heyy im a srilankan student studying in china and recently started working with arduino i did my first project with line guiding with 3 sensors it works perfect and i advanced it to 5 sensors 3 in the front and 2 first and the last one little back the code is
define EN1 6
define EN2 5
define IN1 7
define IN2 4
define FORW 1
define BACK 0
define DF_LT_r1 2
define DF_LT_r 12
define DF_LT_c 11
define DF_LT_l 10
define DF_LT_l1 1
define MOD_SEL 9
void Motor_Control(int M1_DIR,int M1_EN,int M2_DIR,int M2_EN) { //////////M1//////////////////////// if(M1_DIR==FORW) digitalWrite(IN1,HIGH); else digitalWrite(IN1,LOW); if(M1_EN==0) analogWrite(EN1,LOW); else analogWrite(EN1,M1_EN); ///////////M2////////////////////// if(M2_DIR==FORW)//M2 digitalWrite(IN2,HIGH); else digitalWrite(IN2,LOW); if(M2_EN==0) analogWrite(EN2,LOW); else analogWrite(EN2,M2_EN); } void setup() { } void loop() { int L_LT,C_LT,R_LT,L1_LT,R1_LT; int L_Val,C_Val,R_Val,L1_Val,R1_Val; if(LOW == digitalRead(MOD_SEL))
while(1)
{
L1_LT=digitalRead(DF_LT_r1); L_LT=digitalRead(DF_LT_r); C_LT=digitalRead(DF_LT_c); R_LT=digitalRead(DF_LT_l); R1_LT=digitalRead(DF_LT_l1); delay(10); L1_Val=digitalRead(DF_LT_r1); L_Val=digitalRead(DF_LT_r); C_Val=digitalRead(DF_LT_c); R_Val=digitalRead(DF_LT_l); R1_Val=digitalRead(DF_LT_l1);
if(L1_LT==L1_Val&& L_LT==L_Val&&C_LT==C_Val&&R_LT==R_Val&&R1_LT==R1_Val)
{ if(C_LT==LOW&& L_LT==HIGH && R_LT==HIGH&& L1_LT==HIGH && R1_LT==HIGH)
{
Motor_Control(FORW,150,FORW,150);
}
else if (L1_LT==HIGH && L_LT==LOW&& C_LT==LOW&& R_LT=LOW&&R1_LT==HIGH) {
Motor_Control(BACK,200,FORW,200); } else if(L1_LT==LOW&& L_LT==HIGH&& C_LT==LOW&& R_LT=HIGH&&R1_LT==LOW) {
Motor_Control(FORW,150,FORW,150); }
else if(L_LT==LOW &&(C_LT== HIGH||C_LT==LOW)&& R_LT==HIGH&& L1_LT==HIGH&& R1_LT==HIGH) {
Motor_Control(BACK,150,FORW,150); } else if(R_LT==LOW &&(C_LT== HIGH||C_LT==LOW) &&R1_LT==HIGH && L_LT==HIGH&& L1_LT==HIGH) {
Motor_Control(FORW,150,BACK,150); } else if(L1_LT==LOW &&(L_LT== HIGH||L_LT==LOW)&& R_LT==HIGH&& C_LT==HIGH&& R1_LT==HIGH) {
Motor_Control(BACK,200,FORW,200); } else if(R1_LT==LOW &&(R_LT== HIGH||R_LT==LOW) &&R_LT==HIGH && C_LT==HIGH&& L1_LT==HIGH) {
Motor_Control(FORW,200,BACK,200); }
else if(R_LT==HIGH&&C_LT== HIGH&& L_LT==HIGH&& R1_LT== HIGH&& L1_LT==HIGH) {
Motor_Control(FORW,100,BACK,100); delay(10); } else Motor_Control(FORW,0,BACK,0); delay(20) ; } } } but
else if (L1_LT==HIGH && L_LT==LOW&& C_LT==LOW&& R_LT=LOW&&R1_LT==HIGH) {
Motor_Control(BACK,200,FORW,200); }
it gives me a compiling error AS Ivalue required as left operand assignment tried to fix it its going no where your help is highly appreciated please help me fix it since i ve no one to ask here thankyou! best regards , biman