I'm using Arduino uno, fm transmitter and LCD, I'm trying to change the frequency every minute or more. both for and if loop works alone.
Mod edit: code tags
C:
//#include <FMTX.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);
float fm_freq;
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
lcd.backlight();
// Serial.begin(9600);
// Serial.print("FM-TX Demo\r\n");
//
// fmtx_init(fm_freq, CHINA);
//
// Serial.print("Channel:");
// Serial.print(fm_freq, 1);
// Serial.println("MHz");
}
void loop() {
for(fm_freq=89.6;fm_freq<=108;fm_freq=fm_freq+0.2){
delay(200);
lcd.setCursor(0,0);
lcd.print("FM frequncy");
lcd.setCursor(0,1);
lcd.print(fm_freq,1);//print the freq on the lcd with
}
// put your main code here, to run repeatedly:
//
// if(Serial.available()){
// switch(Serial.read()){
// case '&':
// u8 i,buf[4];
// float ch;
// i=0;
// delay(30);
// while(Serial.available()&&i<4){
// buf[I]=Serial.read();
// if (buf[I]<= '9' && buf[I]>= '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 88Mhz to 108Mhz.");
// }
// }else{
// Serial.println("ERROR:Input Format Error.");
// }
//
// while(Serial.available()){
// Serial.read();
// }
// break;
// }
// }
}
Last edited by a moderator: