I listening 98.0 frequency and i wanna change freq. in serial monitor but serial monitor format is ascii. So, it type is integer. My frequency variable type is double.
If i wanna change it , i am afraid i must be write new function,right ?
If i wanna change it , i am afraid i must be write new function,right ?
No. The Serial class inherits from the Stream class, which has parseInt() and parseFloat() that let you type numbers, and converts the stream of characters to int or float.
Hi again me ,I working on RDA5807m radio module(i wanna learn i2c protocol) and i find this code but i dont know mean this code can your help me ?
#include <Wire.h>
unsigned char frequencyH = 0;
unsigned char frequencyL = 0;
unsigned int frequencyB;
double frequency = 0;
void setup()
{
Wire.begin();
frequency = 100.0 ; //starting frequency
setFrequency();
}
void loop()
{
}
void setFrequency()
{
frequencyB = 4 * (frequency * 1000000 + 225000) / 32768; // ??
frequencyH = frequencyB >> 8; // ??
frequencyL = frequencyB & 0XFF; // ??
delay(1000);
Wire.beginTransmission(0x60); // i know this code mean
Wire.write(frequencyH); // what is it mean
Wire.write(frequencyL); // and it
Wire.write(0xB0); // and it
Wire.write(0x10); // and it
Wire.write((byte)0x00); //and it
Wire.endTransmission(); // i know this code mean :D
}
I wanna use RDA5807m mode not tea5767 some body help me ?
I writing in 0x03 but it is not same to my wrote values.İt is 4FC0 but i wrote 1B80.
ı calculated frequency ch space(kHz) X frequency([15:6]10bit) + 87000
for ex;
100 X 110 + 87000 = 98000 so 98Mhz. (110 = 0b01101110) if i wanna do ten bit (0b0001101110) and six bit 000000
=> (00011011)(10000000) first byte 0x1B second byte 0x80; then
I try write this but i hear nothing pls help mee
#include <Wire.h>
unsigned char x,y;
void setup()
{
Serial.begin(9600);
Wire.begin();
setFrequency();
}
void loop()
{
Wire.beginTransmission(0x11);
Wire.write (0x03); // request 6 bytes from slave device #2
Wire.endTransmission();
Wire.beginTransmission(0x11); // base address
Wire.requestFrom(0x11,2); // We want one byte
x=Wire.read();
y=Wire.read();
Serial.println(x,HEX); // print the character
Serial.println(y,HEX);
delay(1000);
}
void setFrequency()
{
delay(500);
Wire.beginTransmission(0x11);
Wire.write(0x02);
Wire.write(0xC0); Wire.write(0x0D); // write 0xC00D (RDS on etc.) into 0x02
Wire.endTransmission();
delay(500);
Wire.beginTransmission(0x11);
Wire.write(0x03);
Wire.write(0x1B);
Wire.write(0x80);
Wire.endTransmission();
}