Guest User

FM Radio

a guest
Nov 9th, 2017
487
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <TEA5767.h>
  2. #include <Wire.h>
  3.  
  4. TEA5767 Radio;
  5.  
  6. double frequency, current_freq;
  7. int search_mode = 0, stereo, signal_level, search_direction;
  8. unsigned char buf[5];
  9. unsigned long current_millis = millis(), last_pressed;
  10.  
  11. void setup () {
  12.   pinMode(8, INPUT);
  13.   pinMode(10, INPUT);
  14.   Radio.init();
  15.   Radio.set_frequency(95.2);
  16. }
  17.  
  18. void loop () {
  19.   if (Radio.read_status(buf) == 1) {
  20.      current_freq =  floor (Radio.frequency_available (buf) / 100000 + .5) / 10;
  21.      stereo = Radio.stereo(buf);
  22.      signal_level = Radio.signal_level(buf);
  23.   }
  24.   if (search_mode == 1) {
  25.       if (Radio.process_search (buf, search_direction) == 1) {
  26.           search_mode = 0;
  27.       }
  28.   }
  29.   if (digitalRead(8) == HIGH) {
  30.     last_pressed = current_millis;
  31.     search_mode = 1;
  32.     search_direction = TEA5767_SEARCH_DIR_UP;
  33.     Radio.search_up(buf);
  34.   }
  35.   if (digitalRead(10) == HIGH) {
  36.     last_pressed = current_millis;
  37.     search_mode = 1;
  38.     search_direction = TEA5767_SEARCH_DIR_DOWN;
  39.     Radio.search_down(buf);
  40.   }
  41.   delay(200);
  42. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×