SMK Binawiyata Sragen

  • This is default featured slide 1 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 2 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 3 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 4 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 5 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Membuat Radio Digital FM Stereo dng Arduino

Membuat Radio penerima FM Stereo dengan arduin. Bagi teman teman yang ingin membuat radio FM digital kali ini saya ingin sharing cara membuat dan bahan bahan yang digunakan untuk membangun radio FM digital Stereo dengan tampilan display LCD 16x2. Nah ndak perlu panjang lebar cerita langsung aja :

Bahan yanh diperlukan antara lain :
1. Modul Arduino UNO R3
2. LCD 16x2 warna terserah anda
3. 2 Push Button untuk seting radio
4. 2 LED indikator Flashing dan Alarm
5. 4 Resistor 1K
6. 2 Resistor 220 Ohm
7. Modul Tuner TEA5767
8. IC24C04 untuk menyimpan data memory
9. Kabel jumper secukupnya

Modul Arduino UNO R3

Modul FM TEA5767
LCD 16x2

Block TEA5767 dengan memori
Rangkaiannya :
Skema belum jadi donk :


Source Kodenya Ini Lho :
// Membuat Jam dan Radio FM TEA5767
// LIKNO01
// Programmer Suparno, S.Pd, M.Pd
// 24/01/2015
#include < avr/io.h>
#include < avr/interrupt.h>
#include < LiquidCrystal.h>
#include < Wire.h>
#include < EEPROM.h>
#define debug 0

byte LedPin=8;
byte LedPin2=9;
byte e1Pin=12;
byte e2Pin=13;

byte jam,menit,detik;
byte Ajam,Amenit,Adetik;
byte flag=1;
int sleep;
byte alarm;  //0-1 alarm ON, 3-alarm OFF

char VARI[20];
int z,zz;
byte bz;

unsigned char frequencyH = 0;
unsigned char frequencyL = 0;

unsigned int frequencyB;
double frequency = 0;
byte bfrequency;
double gfrequency;
byte rdata[7];
byte signal;
int reading;


char *menu[]={" ","SLEEP","MODE_MEMO","MODE_SCAN","MODE_DIAL","ALARM","MEMORY","LEVEL-SCAN","TIME"};
char *menu1[]={" ","DIAL","CH: ","SCAN"};//mymode

byte bmemory;
byte memo;
byte mymenu;
byte mymode;
byte mylevel;
byte flag2;


LiquidCrystal lcd(7,6,5,4,3,2);


void setup(){
  Serial.begin(9600);
  lcd.begin(16, 4);
  Wire.begin();
  pinMode(LedPin, OUTPUT);
  pinMode(LedPin2, OUTPUT);
  pinMode(e1Pin, INPUT);
  pinMode(e2Pin, INPUT);
  //==================================
  lcd.setCursor(-4,2);
  lcd.print("Radio FM Mikro");
  lcd.setCursor(-4,3);
  lcd.print("Prog. : Suparno");
  //==================================
  cli();
  TCCR1A=0;
  TCCR1B=0;
  OCR1A=15624;
  TCCR1B |= (1<  TCCR1B |= (1<  TCCR1B |= (1<  TIMSK1=(1<  sei();
  mymenu=0;
  mymode=2;  //si queremos que cuando se encienda la radio este en modo Dial poner 1
  mylevel=2;
  sleep=0;
  alarm=3;
  memo=0;
  flag2=0;
 
  bfrequency = EEPROM.read(0);
  frequency=875+bfrequency;    //aslinya :875         
  frequency/=10;
  setFrequency(); 
 
}

void loop()
{   

   if(!digitalRead(e1Pin))
        {
         mymenu++;        
         if(mymenu>8)mymenu=0;
         lcd.clear();
         lcd.setCursor(0,0);
         lcd.print(menu[mymenu]);
         if(flag2==1)mymenu=0;
         flag2=0;
         delay(100);
         while(!digitalRead(e1Pin));
        }        
      
  switch(mymenu)
    {     
      case 0:     
        switch(mymode)
           {
            case 1:
                reading = analogRead(0); 
               frequency = ((double)reading * (108.0 - 87.5)) / 1024.0 + 87.5;
                 frequency = ((double)reading * 20.5) / 1024.0 + 87.5;
                frequency = ((int)(frequency * 10)) / 10.0;
               
                setFrequency();
                if(!digitalRead(e2Pin))
                     {
                       if(debug)Serial.println(bfrequency);
                       while(!digitalRead(e2Pin));
                     }
               
            break;
            case 2:
                if(!digitalRead(e2Pin))
                     {
                       memo++;
                       if(memo>19)memo=0;                      
                       bfrequency = EEPROM.read(memo);
                       frequency=875+bfrequency;              
                       frequency/=10;
                       setFrequency();              
                       while(!digitalRead(e2Pin));
                     }                        
            break;
            case 3:
                if(!digitalRead(e2Pin))
                     {
                      menuScan();
                      while(!digitalRead(e2Pin));                                           
                     }             
            break;  
           }
         
        lcd.setCursor(0,0);
        lcd.print(frequency);
        lcd.print(" MHz ");
               
        if(flag)
          {
           flag=0;
           if(alarm==1) { sleep=10; alarm=0;}
          
           if(sleep<1 br="">               {
                digitalWrite(LedPin2,LOW);
                lcd.setCursor(12,0);
                lcd.print("OFF ");
               }
             else
              {              
                if(!digitalRead(LedPin2))
                   {
                    digitalWrite(LedPin2,HIGH);
                    delay(500);
                    setFrequency();
                    delay(500);
                    setFrequency();
                   }
                getDatos();  
                signal=rdata[4] >> 4;
                lcd.setCursor(12,0);
                if(detik & 2)
                  {
                   lcd.print("Pw");  
                   lcd.print(signal);
                   lcd.print("  ");
                   }
                 else
                   {
                    if(rdata[3] & 128)
                        lcd.print("STE ");
                     else
                        lcd.print("MONO");
                   }    
              }
              
           lcd.setCursor(0,1);
           lcd.print(menu1[mymode]);
           if(mymode==2)
             {
               lcd.print(memo);
               lcd.print("  ");
             }
          
           lcd.setCursor(6, 1);
           if(alarm==3)
               lcd.print(" ");
              else
               lcd.print("A");            
          
           digitalWrite(LedPin, !digitalRead(LedPin));   
           sprintf(VARI,"%02d:%02d:%02d",jam,menit,detik);
           if(debug)Serial.println(VARI);
           lcd.setCursor(8, 1);
           lcd.print(VARI);  
 
                    
           }     
      break;        
      case 1:
         lcd.setCursor(0,1);
         lcd.print(sleep);
         lcd.print(" menit ");
         if(!digitalRead(e2Pin))
             {
               if(sleep>11)
                   sleep-=10;
                  else
                   sleep--;
               if(sleep<0 sleep="60;<br">               flag2=1;
               while(!digitalRead(e2Pin));
             }        
      break;     
      case 2:
         if(!digitalRead(e2Pin))
             {
               mymode=2;
               mymenu=0;
               bfrequency = EEPROM.read(memo);                      
               frequency=875+bfrequency;
               frequency/=10;
               setFrequency();             
               while(!digitalRead(e2Pin));
             }         
      break;     
      case 3:        
         if(!digitalRead(e2Pin))
             {
               mymode=3;
               mymenu=0;
               while(!digitalRead(e2Pin));
             }         
      break;
      case 4:
         if(!digitalRead(e2Pin))
             {
               mymode=1;
               mymenu=0;
               while(!digitalRead(e2Pin));              
             }                  
      break;
  
    case 5:
         sprintf(VARI,"%02d:%02d",Ajam,Amenit);         
         lcd.setCursor(0, 1);
         lcd.print(VARI);
          if(!digitalRead(e2Pin))
             {            
              menuAlarm();
              mymenu=0;
              lcd.clear();
               while(!digitalRead(e2Pin));
             }      
      break; 
      case 6:
          if(!digitalRead(e2Pin))
                     {
                      menuMemory();
                      while(!digitalRead(e2Pin));
                      lcd.clear();
                      mymenu=0;                     
                     }       
      break;
      case 7:
         lcd.setCursor(0,1);
         lcd.print(mylevel);   
         if(!digitalRead(e2Pin))
             {                         
               mylevel++; if(mylevel>3)mylevel=1;
               flag2=1;             
               while(!digitalRead(e2Pin));
             }         
      break;   
      case 8:
          sprintf(VARI,"%02d:%02d",jam,menit);         
          lcd.setCursor(0, 1);
          lcd.print(VARI);
          if(!digitalRead(e2Pin))
             {             
              menuTime();
              mymenu=0;
              lcd.clear();
              while(!digitalRead(e2Pin));
             }      
      break;    
     
    }

}

void calculo()
{
     bfrequency=frequency*10-875;
     frequencyB = 4 * (frequency * 1000000 + 225000) / 32768;
     frequencyH = frequencyB >> 8;
     frequencyL = frequencyB & 0XFF;
}

void menuMemory()
{
     lcd.setCursor(0,1);
     lcd.print(memo);
     lcd.setCursor(8,0);
     lcd.print(frequency);
     delay(500);
     while(1)
      {
       if(!digitalRead(e2Pin))
                     {
                       memo++;
                       if(memo>19)memo=0;
                       lcd.setCursor(0,1);
                       lcd.print(memo);
                       lcd.print("  ");                      
                       while(!digitalRead(e2Pin));
                     } 
       if(!digitalRead(e1Pin))
                     {
                       if(debug)Serial.println(memo);
                       if(debug)Serial.println(bfrequency);
                       EEPROM.write(memo,bfrequency );
                       while(!digitalRead(e1Pin));
                       return;
                     }       
      }
}

void menuScan()
{                    
                      delay(100);
                      frequency+=0.1;
                      if(frequency>108)frequency=88.5;
                      calculo();
                      bz=mylevel<<5 br="">                      bz=bz | 0x90;
                      Wire.beginTransmission(0x60);
                      Wire.write(frequencyH+0x40);
                      Wire.write(frequencyL);
                      Wire.write(bz);
                      Wire.write(0x1F);
                      Wire.write((byte)0x00);      
                      Wire.endTransmission();
                      delay(100);                                                                        
                      getDatos();
                      gfrequency=(((rdata[1]&0x3F)<<8 br="" rdata="">                      if(debug)for (int i=1; i<6 br="" i="" rdata="" serial.println="">                      frequency=gfrequency/10000;
                      if(debug)Serial.println(frequency);
                      z=frequency;
                      zz=z+5;     z/=10;   zz/=10;
                      if(debug)Serial.println(z);
                      if(debug)Serial.println(zz);
                      if(zz>z)
                         frequency=zz;
                        else
                         frequency=z;
                      frequency/=10;
                      if(debug)Serial.println(frequency);
                      calculo();
                      delay(100);
                      Wire.beginTransmission(0x60);
                      Wire.write(frequencyH);
                      Wire.write(frequencyL);
                      Wire.write(0xB0);
                      Wire.write(0x1F);
                      Wire.write((byte)0x00);      
                      Wire.endTransmission();
                      delay(100);             
}

void menuAlarm()
{
   while(1)
    {
     lcd.setCursor(0,1);
     lcd.print("Alarm   ");
     if(alarm==3)
         lcd.print("OFF");
        else
         lcd.print("ON ");
     if(!digitalRead(e2Pin))
             {
              if(alarm==3)
                  alarm=0;
                else
                  alarm=3;                             
              while(!digitalRead(e2Pin));
             }
     if(!digitalRead(e1Pin))
            {
              while(!digitalRead(e1Pin));
              break;        
            } 
    }
 
   while(1)
    {
     lcd.setCursor(0,1);
     lcd.print("Hours   ");
     lcd.print(Ajam);
     lcd.print("  ");
     if(!digitalRead(e2Pin))
             {
              Ajam++;
              if(Ajam==24)Ajam=0;
              while(!digitalRead(e2Pin));
             }
     if(!digitalRead(e1Pin))
            {
              while(!digitalRead(e1Pin));
              break;        
            } 
    }
  while(1)
    {
      lcd.setCursor(0,1);
      lcd.print("Minutes ");
      lcd.print(Amenit);
      lcd.print("  ");
      if(!digitalRead(e2Pin))
             {
              Amenit++;
              Adetik=0;
              if(Amenit==60)Amenit=0;
              while(!digitalRead(e2Pin));
             }
      if(!digitalRead(e1Pin))
            {
              while(!digitalRead(e1Pin));
              break;        
            } 
    }   


void menuTime()
{
  while(1)
    {
     lcd.setCursor(0,1);
     lcd.print("Hours   ");
     lcd.print(jam);
     lcd.print("  ");
     if(!digitalRead(e2Pin))
             {
              jam++;
              if(jam==24)jam=0;
              while(!digitalRead(e2Pin));
             }
     if(!digitalRead(e1Pin))
            {
              while(!digitalRead(e1Pin));
              break;        
            } 
    }
  while(1)
    {
      lcd.setCursor(0,1);
      lcd.print("Minutes ");
      lcd.print(menit);
      lcd.print("  ");
      if(!digitalRead(e2Pin))
             {
              menit++;
              detik=0;
              if(menit==60)menit=0;
              while(!digitalRead(e2Pin));
             }
      if(!digitalRead(e1Pin))
            {
              while(!digitalRead(e1Pin));
              break;        
            } 
    }   
}


void setFrequency()
{
calculo();
//delay(100);
Wire.beginTransmission(0x60);
Wire.write(frequencyH);
Wire.write(frequencyL);
Wire.write(0xB0);
Wire.write(0x10);
Wire.write((byte)0x00);
Wire.endTransmission();
//delay(100);
}

void getDatos()
{
  Wire.requestFrom(0x60,5); //reading TEA5767
  if (Wire.available())
    {
      for (int i=1; i<6 br="" i="" rdata="" wire.read="">    }
}

ISR(TIMER1_COMPA_vect) //alarm yake
{
  flag=1;
  detik++;
  if(detik>59)
    {
     detik=0;
     menit++;
     if(sleep>0)sleep--;
     if(menit>59)
         {
          menit=0;
          jam++;
            if(jam>23)
              {              
               detik=0;
               menit=0;
               jam=0;
              }
         }
    }
  if(alarm==0 && detik==0 && menit==Amenit && jam==Ajam)alarm=1;     
}




Share:

Jadwal Waktu Sholat

TIME WIB

TV EDUKASI LIVE

Popular Posts

Recent Posts

Pages