FM Selection Frequency with Tea5767 and Oled SDD1306
1. Material
- Resistor 10K : 2
- SSD1306 Oled Led : 1
- Tea5767 Radio Modulation :1
- pushButton : 2
- Ardunio Uno :1
More Information
==> Click here
==> Click here
All Library Here:
==> Cli ck Here
Code In Here With Serial
#include<Wire.h>
#include<TEA5767N.h>
TEA5767N Radio = TEA5767N(); // using Standard I2C pins A4 and A5
#define MUTEPIN 2
#define STATIONPIN 3
int flag=0;
double stations[]={105.5,105.7,105.9,105.1,105.2};
int currentstation=0;
int maxstation =2;
bool mutestate=0;
void setup(){
Serial.begin(9600);
Serial.println("Ardunio Fm radio example ");
pinMode(MUTEPIN, INPUT);
pinMode(STATIONPIN,INPUT);
Radio.selectFrequency(stations[currentstation]); // power on with the first station
delay(250);
}
void loop(){
if(digitalRead(MUTEPIN)==0){
mutestate=! mutestate;
if(mutestate){
Serial.println("Muting Radio ");
Radio.mute();
}else{
Serial.println("Unmuting radio");
Radio.turnTheSoundBackOn();
}
}
if(digitalRead(STATIONPIN)==0){
Serial.println("Tuning to next station");
currentstation++;
if(currentstation>maxstation){
currentstation=0;
}
Radio.selectFrequency(stations[currentstation]);
flag=0;
delay(250);
}
if(flag==0){
Serial.println("Current fre: ");
Serial.print(Radio.readFrequencyInMHz());
Serial.print("Mhz Signal ");
Serial.print(Radio.isStereo()? "STEREO":"MONO");
Serial.print(" ");
Serial.print(Radio.getSignalLevel());
Serial.println("/20");
flag=1;
}
delay(100);
}
Code with Oled
#include<SPI.h>
#include<Wire.h>
#include<TEA5767N.h>
#include<Adafruit_SSD1306.h>
const unsigned char myBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc6, 0x1d, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x1e, 0x7c, 0x6c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x2f, 0xbc, 0xa4,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x1a, 0x28, 0xb0, 0xa4,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x1a, 0x30, 0xe1, 0xa4,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x80, 0x00, 0x00, 0x0c, 0x31, 0x60, 0xf4,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xf0, 0x00, 0x00, 0x07, 0x9e, 0x79, 0xf8,
0x03, 0x0e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x06, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x06, 0x35, 0x00, 0x00, 0x08, 0x42, 0x00, 0x7f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x16, 0x35, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00,
0x03, 0x0a, 0x35, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x80, 0x00, 0x00,
0x02, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x80, 0x00, 0x00,
0x03, 0x86, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00,
0x02, 0xcd, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00,
0x02, 0xcd, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0x02, 0xcd, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0x01, 0x86, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0x80, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xc0, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0x04, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x02, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x03, 0x8c, 0x30, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x02, 0x8c, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00,
0x02, 0x8c, 0x50, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xc0, 0x00, 0x00,
0x02, 0x8c, 0x50, 0xff, 0xfe, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0x80, 0x00, 0x00,
0x03, 0x84, 0x78, 0xff, 0xf8, 0x00, 0x07, 0xff, 0xff, 0xff, 0xfe, 0x01, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xfc, 0x00, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfe, 0x01, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xc0, 0x3f, 0x00, 0xff, 0xff, 0xff, 0xff, 0x87, 0xff, 0x80, 0x00, 0x00,
0x00, 0x38, 0xd8, 0xff, 0x80, 0x7f, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
0x00, 0xe2, 0x68, 0xff, 0x80, 0x7f, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
0x03, 0xf2, 0x68, 0xff, 0x80, 0x7f, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0e, 0x1c,
0x00, 0xe6, 0xe8, 0xff, 0x80, 0x7f, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x34, 0x1c,
0x00, 0xe2, 0x68, 0xff, 0xc0, 0x3f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x7e, 0x00,
0x00, 0xe2, 0x68, 0xff, 0xc0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x73, 0x08,
0x00, 0xc6, 0x48, 0xff, 0xe0, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x7f, 0x08,
0x07, 0x80, 0x00, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x6a, 0x10,
0x00, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x3c, 0x10,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Adafruit_SSD1306 oled(LED_BUILTIN);
TEA5767N Radio = TEA5767N(); // using Standard I2C pins A4 and A5
#define MUTEPIN 2
#define STATIONPIN 3
int flag=0;
double stations[]={105.5,105.7,105.9,105.1,105.2};
int currentstation=0;
int maxstation =2;
bool mutestate=0;
void setup(){
oled.begin(0x3c);
oled.clearDisplay();
oled.drawBitmap(0,0,myBitmap,124,64,WHITE);
oled.display();
delay(1000);
oled.clearDisplay();
pinMode(MUTEPIN, INPUT);
pinMode(STATIONPIN,INPUT);
Radio.selectFrequency(stations[currentstation]); // power on with the first station
delay(250);
}
void loop(){
if(digitalRead(MUTEPIN)==0){
mutestate=! mutestate;
if(mutestate){
Serial.println("Muting Radio ");
Radio.mute();
}else{
Serial.println("Unmuting radio");
Radio.turnTheSoundBackOn();
}
}
if(digitalRead(STATIONPIN)==0){
Serial.println("Tuning to next station");
currentstation++;
if(currentstation>maxstation){
currentstation=0;
}
Radio.selectFrequency(stations[currentstation]);
flag=0;
delay(250);
}
if(flag==0){
oled.clearDisplay();
oled.setTextColor(WHITE);
oled.setCursor(15, 15);
oled.setTextSize(2);
oled.println("Frequency");
oled.println();
oled.print(Radio.readFrequencyInMHz());
oled.print("Mhz");
//oled.print(Radio.isStereo()? "STEREO":"MONO");
oled.println(Radio.getSignalLevel());
flag=1;
oled.display();
}
delay(100);
}