I was making a drone's transmitter
Arduino Ide is showing "Compilation error: expression cannot be used as a function"
Can anyone fix this?
Here is the code
```cpp
#include <RF24.h>
#include <RF24_config.h>
#include <nRF24L01.h>
#include <printf.h>
#include <SPI.h>
RF24 radio(7, 8);
const byte(address) = "node1";
void setup() {
// put your setup code here, to run once:
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MAX);
pinMode(4, INPUT);
pinMode(5, INPUT);
}
struct datapack {
bool toggleSwitch1 = 0;
bool toggleSwitch2 = 0;
int joystickLeft_x;
int joystickLeft_y;
int joystickRight_x;
int joystickRight_y;
};
datapack data;
void loop() {
// put your main code here, to run repeatedly:
data.toggleSwitch1(digitalRead(4));
data.toggleSwitch2(digitalRead(5));
data.joystickLeft_x = map(analogRead(A0), 0, 1023, 0, 255);
data.joystickLeft_y = map(analogRead(A1), 0, 1023, 0, 255);
data.joystickRight_x = map(analogRead(A2), 0, 1023, 0, 255);
data.joystickRight_y = map(analogRead(A3)), 0 , 1023 , 0 , 255);
radio.write(&data, sizeof(data));
}
For success on this forum, you'll have to learn to work with those who want to help. Please, edit your message to use code tags, and provide the complete error capture. Last request.
By the way, this line is incorrect, near as I can tell. data.joystickRight_y = map(analogRead(A3)), 0 , 1023 , 0 , 255)
count the brackets opening and closing. Oh, and it's missing the semicolon at the end.
See I have recently come to Arduino Forum please cooperate and Please can you send the revised code by fixing all the errors. I can't understand how to basically revice the code
This means "call a function named digitalRead passing 4 as parameter", which will return some value. Take this value and then pass it as parameter to another function named "toggleSwitch1"
This is a user-forum. A user-forum is really different from WhatsApp, Telegram, etc.
Posting something short like
Does not even say what you will try
If you like to snapp-chatter. Use snap-chat
If you want really help then
I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster.
This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.
Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.