Elechouse transmitter not working

Hi all,

I bought a little Elechouse FM transmitter (http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=168_170&products_id=2206) and got it working without too much drama on my Arduino Uno. I’m trying to get it to work on my trinket, to make a miniature transmitter for my car.

The trouble is that when I try and compile the code it always comes up with the message ‘serial was not declared in this scope’, despite my including the SoftwareSerial.h library. I’ve posted the code below. Can anyone tell me if I’m doing anything stupid?

#include <SoftwareSerial.h>

/**
@file fmrx_demo.ino
@author www.elechouse.com
@brief example of FMRX_MODULE

For this demo, input command format like &xxxx to set select band,
(eg:if you want to set FM 95.6MHz,then input &0956 and send).

@section HISTORY

V1.0 initial version

Copyright (c) 2012 www.elechouse.com All right reserved.
*/

#include <FMTX.h>

float fm_freq = 90; // Here set the default FM frequency
void setup(void)
{

Serial.begin(9600);
Serial.print(“FM-TX Demo\r\n”);
/**
Initial, set FM channel and select your area:
USA
EUROPE
JAPAN
AUSTRALIA
CHINA
*/
fmtx_init(fm_freq, USA);
Serial.print(“Channel:”);
Serial.print(fm_freq, 1);
Serial.println(“MHz”);
}

void loop(void)
{
/** check for data setting new frequency. Users could input data from Serial monitor. Data
must start with ‘&’ and followed by 4 numbers, such as &8000. The first two is the integer part
of new frequency (Unit: MHz), and the last one is the decimal part. And the channel must between 70MHz
and 108Mhz. For example, &756 is 75.6MHz, and &666 is out of range.
*/
if(Serial.available()){
switch(Serial.read()){
case ‘&’:
u8 i,buf[4];
float ch;
i=0;
delay(30);
while(Serial.available()&&i<4){
buf=Serial.read();
if (buf<= ‘9’ && buf>= ‘0’) {
i++;}
else{
i=0;
break;
}
}
if (i==4){
ch = (buf[0]-‘0’)*100+(buf[1]-‘0’)*10+(buf[2]-‘0’)1+0.1(buf[3]-‘0’);
if(ch>=70&&ch<=108){
Serial.print(“New Channel:”);
Serial.print(ch, 1);
Serial.println(“MHz”);
fmtx_set_freq(ch);
}else{
Serial.println(“ERROR:Channel must be range from 70Mhz to 108Mhz.”);
}
}else{
Serial.println(“ERROR:Input Format Error.”);
}

while(Serial.available()){
Serial.read();
}
break;
}
}
}

Ok you need to post your code in code tags. top left button on the post editor.

and got it working without too much drama on my Arduino Uno.

Are you sure? Doesn’t compile for me.

For example:

buf=Serial.read();
if (buf<= '9' && buf>= '0') {

buf is an array of 4, you have to assign a index to write your byte to. This gives me a compilation error.

Also for software serial, you specify and use your own serial name:

// global
SoftwareSerial mySerial(10, 11); // RX, TX

// setup
// set the data rate for the SoftwareSerial port
  mySerial.begin(4800);

// loop wherever you want to print
mySerial.println("Hello, world?");

SoftwareSerial