Go Down

Topic: code for receiving serial data from transmitter (Read 486 times) previous topic - next topic

arduino_learners

hi everyone,im working on flood monitoring system.here my arduino code for receiving data serially..is it this code really work?
im receiving the latitude and longitude data from the transmitter as well as the water level data..is there any changes that i have to make in order to get the code work?sorry, im very new with arduino board...tq for ur help...
Code: [Select]

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

int rate;

void setup(){

  Serial.begin(9600);

  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();
  Mirf.setRADDR((byte *)"serv1");
  Mirf.payload = sizeof(rate);
  Mirf.config();
}

void loop(){

  while(!Mirf.dataReady()){
  }
  Mirf.getData((byte *) &rate);

  Serial.println(rate);
  delay(100);
}

Graynomad

#1
Dec 11, 2012, 09:37 am Last Edit: Dec 11, 2012, 09:44 am by Graynomad Reason: 1
I've no idea what Mirf.getData() does but

Code: [Select]
int rate;
...
Mirf.getData((byte *) &rate);


doesn't seem right. Why are you casting the address of an int to a pointer to a byte?

If Mirf.getData() fills "rate" with more that 2 bytes you will be in trouble.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

arduino_learners

i got the code online...refering to the code...there are no initialization of pin...does it works?

AWOL

Quote
.there are no initialization of pin...does it works?

You're the one with the hardware - you tell us.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up