Hey!!
I am currently doing a project using arduino..
I have 3 arduinos.. Frst one is sending a data coming from gyroscope to the second arduino wirelessly and it comes in perfect shape and as fast as i want.
Now I'm trying to send this data that arrived to the second arduino to the third one, but this time by jumping wire through D(3,5,6,9,10,11) the PWM I\O. I used this code when I serial monitor the data in Arduino 3 it's coming very slow comparing to the data coming to the second arduino. ANY SUGGESTION??!!
I have to receive the data in D (8,9,10,11) ports.
the code for the second arduino ...
//start
//Add the necessary libraries
//You can find all the necessary library links in the video description
#include <SPI.h> //SPI library for communicate with the nRF24L01+
#include "RF24.h" //The main library of the nRF24L01+
//Define packet for the direction (X axis and Y axis)
int data[3];
//Define object from RF24 library - 9 and 10 are a digital pin numbers to which signals CE and CSN are connected
RF24 radio(5,6);
//Create a pipe addresses for the communicate
const uint64_t pipe = 0xE8E8F0F0E1LL;
#include <PWM.h>
//use pin 11 on the Mega instead, otherwise there is a frequency cap at 31 Hz
int led = 9;// quadx connect this pin to pin 8
int led2 = 10 ;// quadx connect this pin to pin 9
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
int32_t frequency = 54; //frequency (in Hz)
void setup()
{
//initialize all timers except for 0, to save time keeping functions
InitTimersSafe();
Serial.begin(115200);
radio.begin(); //Start the nRF24 communicate
radio.openReadingPipe(1, pipe); //Sets the address of the transmitter to which the program will receive data.
radio.startListening();
//sets the frequency for the specified pin
bool success = SetPinFrequencySafe(led, frequency);
//if the pin frequency was set successfully, turn pin 13 on
if(success) {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
}
void loop()
{
if (radio.available()){
radio.read(data, sizeof(data));
// Serial.print( " Throttle=" ); Serial.print( data[0]); Serial.print("\t");
// Serial.print( " Pitch= " ); Serial.print( data[1]); Serial.print("\t");
// Serial.print( " Roll= " );Serial.print( data[2]); Serial.print("\n");
}
int pitch2= map(data[1], 1000,2000,13,28);
int roll2= map(data[2], 1000,2000,13,28);
//use this functions instead of analogWrite on 'initialized' pins
Serial.print( " pitch2= " );Serial.print( pitch2); Serial.print("\t");
Serial.print( " roll2= " );Serial.print( roll2); Serial.print("\n");
pwmWrite(led, pitch2);
pwmWrite(led2, roll2);
delay(50);
}
// End
the code for the third arduino
//start
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(10,INPUT);
pinMode(9,INPUT);
pinMode(11,INPUT);
}
void loop() {
int value = pulseIn(8,HIGH); // pitvh
int value1 = pulseIn(10,HIGH); //roll
int value2 = pulseIn(11,HIGH);
Serial.print("pithc= "); Serial.print(value); Serial.print("\t");
Serial.print("roll= ");Serial.println(value1); Serial.print("\n");
// Serial.print(" pin 10 sends ay: ");
// Serial.print(value1);
// Serial.print(" pin 9 sends ax: ");
// Serial.println(value2);
// put your main code here, to run repeatedly:
}
//End