Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

FM Radio

a guest Nov 9th, 2017 214 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top