Question: I have a problem in my project . I used two Arduino one as transmitter and one as a receiver. the Transmitter is connected to

I have a problem in my project . I used two Arduino one as transmitter and one as a receiver. the Transmitter is connected to 6 IR sensors(TCRT5000) and NRF24L01 which used for wireless communication. The receiver is connected to 2 IR sensors which places at the gate . it also connected to servo motor,I2C LCD and NRF24L01. if there is an available parking the servo will rotate 90 degree. the transmitter code :

#include

#include

#include

RF24 radio(7, 8); // CE, CSN

const byte address[6] = "01001";

int ir1=A0;

int ir2=A1;

int ir3=A2;

int ir4=A3;

int ir5=A4;

int ir6=A5;

int x=500;

void setup() {

Serial.begin(9600);

pinMode(ir1, INPUT);

pinMode(ir2, INPUT);

pinMode(ir3, INPUT);

pinMode(ir4, INPUT);

pinMode(ir5, INPUT);

pinMode(ir6, INPUT);

radio.begin();

radio.openWritingPipe(address);

radio.setPALevel(RF24_PA_MIN);

radio.stopListening();

}

char parks[11];

void loop() {

if(analogRead(ir1)

Serial.println("1");}

else{parks[0]='0';}

if(analogRead(ir2)

Serial.println("2");}

else{parks[2]='0';}

if(analogRead(ir3)

Serial.println("3");}

else{parks[4]='0';}

if(analogRead(ir4)

Serial.println("4");}

else{parks[6]='0';}

if(analogRead(ir5)

Serial.println("5");}

else{parks[8]='0';}

if(analogRead(ir6)

Serial.println("6");}

else{parks[10]='0';}

parks[1]=' ';

parks[3]=' ';

parks[5]=' ';

parks[7]=' ';

parks[9]=' ';

String AvailbleParks(parks);

Serial.println(AvailbleParks);

radio.write(&AvailbleParks, sizeof(AvailbleParks));

delay(10000);}

the receiver code:

#include

#include

#include

#include

#include

#include

Servo myservo;

LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7,3,POSITIVE);

RF24 radio(7, 8);

const byte address[6] = "01001";

String AvailbleParks = " ";

char AvailbleParksArrey[11];

long delay1;

int CarIn=A0;

int CarOut=A1;

int aPark=0;

void setup() {

Serial.begin(9600);

lcd.begin(16,2);

lcd.backlight();

pinMode(A1,INPUT);

pinMode(A0,INPUT);

myservo.attach(9);

radio.begin();

radio.openReadingPipe(0, address);

radio.setPALevel(RF24_PA_MIN);

radio.startListening();}

void loop() {

if (radio.available()) {

radio.read(&AvailbleParks, sizeof(AvailbleParks));

Serial.println(AvailbleParks); }

Serial.println(AvailbleParks);

AvailbleParks.toCharArray(AvailbleParksArrey, 11) ;

lcd.setCursor(0, 0);

lcd.print(AvailbleParks);

for(int i=0;i<11;i++){

if (AvailbleParksArrey[i]!='0' && AvailbleParksArrey[i]!=' ')

{aPark=1;

}else {aPark=0;}}

if(analogRead(A0)<500 && apark==1){

myservo.write(90);

delay1=millis()+5000;

}

if(analogRead(A1)<500 && apark==1){

myservo.write(90);

delay1=millis()+5000;

}

if(delay1

all chips work fine and the transmitter code detect the presence of cars correctly. my problem in the receiver code. I don't know if I missed something important or the order is not correct.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!