understanding CCB code for LM7001 .

Hi,this is my fist post, I am trying to make a fm radio receiver by using LM7001 and i get the Arduino CCB code for LM7001 in here. But i cant understand the code line 33`. Specially the number 114 and 102. And also in code line 80 the number 135. I have search many sites about for this but I can't find any thing about this. please suggest me books or links . Eagerly waiting for your positive response.
sorry for my bad english.

If you speak Russian, you might be better off asking your question in the Russian section.

d123s:
Hi,this is my fist post, I am trying to make a fm radio receiver by using LM7001 and i get the Arduino CCB code for LM7001 in here. But i cant understand the code line 33`. Specially the number 114 and 102. And also in code line 80 the number 135. I have search many sites about for this but I can't find any thing about this. please suggest me books or links . Eagerly waiting for your positive response.
sorry for my bad english.

code from link posted by OP:

// Ports for LM
#define CE 12 // LM7001 PIN3
#define CL 11 // LM7001 PIN4
#define DA 10 // LM7001 PIN5
// Delay on ticks, in microseconds
#define LM_DELAY 2

void setup ()
{
  Serial.begin (9600);
  pinMode (CE, OUTPUT);
  pinMode (CL, OUTPUT);
  pinMode (DA, OUTPUT);
  // Let there be a radio right away!
  // SetRF (1017);
}

void loop ()
{
  int inRF;
  byte p[2];
  int t;

  ReadSteering();

  // The length of the command is 8 bytes, format:
  // rfXXXXX <cr>
  t = Serial.available();
  if (t >= 8)
  {
    p[0] = Serial.read();
    p[1] = Serial.read();
    if (p[0] == 114 and p[1] == 102)
    {
      inRF = 1;
      for (int x = 3; x >= 0; x--)
      {
        inRF += (int (Serial.read()) - 48) * pow (10, x);
      }
      Serial.flush();
      if (inRF >= 875 and inRF <= 1080) {
        SetRF(inRF);
        SendOK();
      }
      else {
        SendERR();
      }
    }
    else {
      SendERR();
    }
  }
  else
  {
    if (t > 0) {
      Serial.flush();
      SendOK();
    }
  }
  delay(100);
}

// Reads the steering buttons and writes the code of the pressed button to the port

void ReadSteering()
{
  byte bytes[2];
  unsigned int res_dt1 = analogRead(0); // read ADC data
  delay(50);
  unsigned int res_dt2 = analogRead(0); // bounce check
  if (abs (res_dt1 - res_dt2) <= 20 and res_dt1 < 1000) // if there is no bounce and something is
  {
    bytes[0] = 255;
    bytes[1] = res_dt1 & 255; // convert to 2 bytes
    bytes[2] = (res_dt1 & 768) >> 8;
    Serial.write(bytes, 3); // send the read value to the computer
  }
  //Serial.print(res_dt1,DEC);
  //Serial.print ("");
  //Serial.println (res_dt2, DEC);
}

void SetRF(int RF)
{
  RF += 107;
  // We expose CE, we say that we write in LM
  digitalWrite(CE, HIGH);
  writeToLM(byte (RF));
  writeToLM(byte (RF >> 8));
  writeToLM(135);
  // Remove CE, all sent
  digitalWrite(CE, LOW);
}

void writeToLM(byte ByteToSend)
{
  int D;
  int D1;

  delayMicroseconds(LM_DELAY);
  for (int x = 0; x <= 7; x ++)
  {
    // Set DA
    D = ByteToSend >> 1;
    D1 = D << 1;
    if (ByteToSend == D1) // So it was 0
    {
      digitalWrite(DA, LOW);
    }
    else
    {
      digitalWrite(DA, HIGH);
    }
    // Form the strobe CL
    digitalWrite(CL, HIGH);
    delayMicroseconds(LM_DELAY);
    digitalWrite(CL, LOW);
    delayMicroseconds(LM_DELAY);
    ByteToSend = ByteToSend >> 1;
  }
  delayMicroseconds(LM_DELAY);
}

void SendOK()
{
  Serial.println("OK");
}

void SendERR()
{
  Serial.println("ER");
}

If I have understood the code corrected the values 114 and 102 are the ASCII decimal values for 'r' and 'f' respectively.

hope that helps....

1 Like