Good Evening. I'm trying to build my first rc car with a dc motor and and servo and i want to controll it with my arrow buttons on my laptop. To do this i am using processing to comunicate with my Nano via Serial port which has a nrf24l01 attached to transmitt the comands to my Uno which has also another nrf24l01.
After days and nights spent learning how to do this i finally came up with some codes either for processing, transmitter and Receiver. The 3 codes are posted Below. This codes are just a simple test i've done to light 4 LED's with the 4 directions i want my car to move in the future.
Now my problem is that my LED's dont turn on. Also my receiver returns "No Radio Available" even when i type the commands on my transmitter Monitor Serie.
I had already tested the GettingStarted example for the transceivers and they are OK! So this must be a problem on the code itself.
Not sure why you're using wifi modules to talk over bluetooth (assuming the protocol; you didn't specify in your post). That is most likely your problem - wrong hardware.
If you want to talk on bluetooth, use a HC-05 module instead. They work like a charm.
Have a look at this Simple nRF24L01+ Tutorial. I am using a development of the the second example to control model trains from a PC - conceptually very similar to what you are doing.
Get simple wireless communication working before you try anything else as the wireless stuff is the hardest to debug.
I am using a browser based control system with the web application written using the Python Bottle web framework. I posted a cut-down version of the whole thing here for another Forum reader. Feel free to use it if it helps.
Power_Broker:
Not sure why you're using wifi modules to talk over bluetooth (assuming the protocol; you didn't specify in your post). That is most likely your problem - wrong hardware.
I dont wanna talk over bluetooth. I want to comunnicate with radio frequency using the nrf24 modules. How am i using bluetooth if i only have read radio examples? Why you say that? I dont understand what i did wrong.
Robin2:
Have a look at this Simple nRF24L01+ Tutorial. I am using a development of the the second example to control model trains from a PC - conceptually very similar to what you are doing.
I already have seen this one. However i am new to this and i dont understand this part of your code:
Robin2:
Get simple wireless communication working before you try anything else as the wireless stuff is the hardest to debug.
I am using a browser based control system with the web application written using the Python Bottle web framework. I posted a cut-down version of the whole thing here for another Forum reader. Feel free to use it if it helps.
...R
I am able to communicate with arduino with my processing code as I can see the nano led blink every time i type the 6 buttons i use to give instructions. I believe that somehow the transmiter is failing to send the message after being received from processing with serial port. I see you are using a different interface to talk to Arduino in that sketch but I would rather doing this with Processing, i hope it isnt a problem?
I've done the codes step by step. First i designed the code in arduino to blink the leds. Then I give the insctructions on processing to comunicate with arduino via serial and being successfull with that.
For the transmiter part I saw a lot of examples for different projects and sometimes it was very awkward or not understandable to me. I tried to be the most simple i can as far as my knowledge permited so i would't run into much truble...So i run a simple code where i blink a set of LED's with push-buttons using radio comunication.
Then i probably fried my brain, smashed both codes and the result was that xD
I will battle once more on the radio part again. Thanks for your patience
tiagowizard:
i dont understand this part of your code:
The piece you quoted is using millis() to figure out when it is time to send a message - every txIntervalMillis milliseconds. By sending at a regular interval the receiver can tell if the communication fails and bring the car to a halt.
If that does not answer your question please let me know more exactly what you need help with.
You need to see your project in at least two different parts.
First you have communication between your PC and the Arduino connected to it. Get that working on its own so you can reliably send data. You may need to add code to your Processing program so that it can display message coming back from the Arduino - for example for testing get it to send back the data it has received. In this part of the project the examples in Serial Input Basics should be useful. Ideally use the system in the 3rd example as it will be most reliable.
Then, second, get a separate program working that can send data wirelessly to another Arduino. The examples in my nRF24 tutorlal should help with that. To start with, just send fixed data. When that works it will only require small change to the code to send data that has come from the PC after you merge the two programs.
Yes i understood perfectly! Thank you a lot for your feedback. What you said made a lot of sense to me.
I'll come back when i got more news (good ones i hope :P) about the project.
Hello guys. As I said I'd come if i had news, I am here to tell you that the news are good and my project keeps on rolling.
Today i successfully turned ON and OFF the 4 leds I'm using to simulate the 4 directions I want my car to move. Thank you for your advice, it was very important. It seems that my biggest problem was my RX code, however i needed some changed on TX too.
Yesterday I started to send data from TX and my RX started receiving it. Although my RX SerialMonitor only returned zeros. To fix this problem i had to reference my variables as:
In TX: radio.write(**&**val,sizeof(val));
In RX: radio.read(**&**val, sizeof(val));
This fixed the problem and i could send and receive each respective char. The code I'm using is very easy to read and understand. I'll let both RX and TX arduino sketch and my Processing Sketch i use to communicate with TX via Serial.Port.
Now, there are some problems I have noticed, which may be something about my processing sketch. I hope you can clarify something first. Here i go again
Imagine that I keep my UP button pressed while i hit RIGHT and LEFT buttons to turn the vehicle. When I hit RIGTH or LEFT my sketch stop receveing UP char's on my RX Serial.Monitor but the LED i use to represent UP position keeps ON.
Now the question is: Would my car stop moving UP when i hit right and left?
If you dont understand my question please ask.
tiagowizard:
To fix this problem i had to reference my variables as:
In TX: radio.write(**&**val,sizeof(val));
That's how it is done in my tutorial
Imagine that I keep my UP button pressed while i hit RIGHT and LEFT buttons to turn the vehicle. When I hit RIGTH or LEFT my sketch stop receveing UP char's on my RX Serial.Monitor but the LED i use to represent UP position keeps ON.
Now the question is: Would my car stop moving UP when i hit right and left?
If you dont understand my question please ask.
If the Tx is sending data several times per second then I suggest it always sends data for the state of all buttons. That way, as far as the wireless is concerned, there would be no difficulty if all the buttons were pressed at the same time, or none of them - or any combination.
After that it is for you to decide what combinations you want to send.