0% found this document useful (0 votes)
9 views2 pages

Arduino Radio with LCD Display Code

The document contains an Arduino sketch that utilizes a TEA5767 radio module and a LiquidCrystal display to scan FM frequencies and display random phrases every 30 seconds. It plays a tone based on the signal strength of the radio stations found. The setup includes initializing the LCD and radio, and the loop continuously scans frequencies while updating the display and playing tones accordingly.

Uploaded by

agthorp34
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Arduino Radio with LCD Display Code

The document contains an Arduino sketch that utilizes a TEA5767 radio module and a LiquidCrystal display to scan FM frequencies and display random phrases every 30 seconds. It plays a tone based on the signal strength of the radio stations found. The setup includes initializing the LCD and radio, and the loop continuously scans frequencies while updating the display and playing tones accordingly.

Uploaded by

agthorp34
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include <Wire.

h>
#include <TEA5767Radio.h>
#include <LiquidCrystal.h>

#define SPEAKER_PIN 6
#define PHRASE_INTERVAL 30000 // 30 seconds
#define DISPLAY_DURATION 3000 // 3 seconds

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);


TEA5767Radio radio;

const char* phrases[] = {


"Is anyone here?",
"Please talk to us.",
"We can hear you.",
"Give us a sign.",
"Are you there?",
"Make a sound."
};
const int numPhrases = sizeof(phrases) / sizeof(phrases[0]);

unsigned long lastPhraseTime = 0;

void setup() {
[Link](16, 2);
pinMode(SPEAKER_PIN, OUTPUT);
[Link]();
[Link](87.5); // Set initial frequency
}

void loop() {
unsigned long currentTime = millis();

// Scan for stations


for (float freq = 87.5; freq <= 108.0; freq += 0.1) {
[Link](freq);
delay(200); // Small delay to tune the frequency

// Play a tone based on the signal strength


int signalStrength = [Link]();
int toneFrequency = map(signalStrength, 0, 100, 500, 2000);
tone(SPEAKER_PIN, toneFrequency, 200); // Play a tone for 200 milliseconds

// Display frequency on LCD


[Link](0, 0);
[Link]("Frequency: ");
[Link]([Link]());
[Link](" MHz");

// Randomly display a phrase every 30 seconds


if (currentTime - lastPhraseTime >= PHRASE_INTERVAL) {
lastPhraseTime = currentTime;
[Link](0, 1);
int phraseIndex = random(numPhrases);
[Link](phrases[phraseIndex]);
delay(DISPLAY_DURATION);
[Link](0, 1);
[Link](" "); // Clear the phrase after 3 seconds
}
delay(800); // Wait for 800 milliseconds before tuning to the next frequency
}
}

You might also like