Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: "Radio Frequency Display"
- - Source Code compiled for: Arduino Nano
- - Source Code created on: 2024-03-15 11:13:36
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* USB Connection to Kenwood TS-590SG radio. Read */
- /* radio operating frequency from radio Serial Data */
- /* (115200 BAUD) Decide which Amateur radio Frequency */
- /* Band the radio's frequency is on, write radio */
- /* frequency and frequency Band to LCD Display */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /******* SYSTEM REQUIREMENTS *******/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* USB Connection to Kenwood TS-590SG radio. Read */
- /* radio operating frequency from radio Serial Data */
- /* (115200 BAUD) Decide which Amateur radio Frequency */
- /* Band the radio's frequency is on, write radio */
- /* frequency and frequency Band to LCD Display */
- /************************************/
- /***** DEFINITION OF I2C PINS *****/
- const uint8_t LCD1602i2c_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
- const uint8_t LCD1602i2c_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
- const uint8_t LCD1602i2c_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27;
- /****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
- LiquidCrystal_I2C lcd(LCD1602i2c_LCD1602I2C_I2C_SLAVE_ADDRESS, 20, 4); // Initialize the LiquidCrystal_I2C object
- void setup(void)
- {
- // put your setup code here, to run once:
- lcd.begin(20, 4); // Initialize the LCD with 20 columns and 4 rows
- lcd.backlight(); // Turn on the backlight
- Serial.begin(115200); // Initialize the Serial communication with the radio
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- if (Serial.available())
- {
- delay(100);
- lcd.clear(); // Clear the LCD screen
- // Read the radio operating frequency from the Serial data
- float frequency = Serial.parseFloat();
- lcd.print("Frequency: ");
- lcd.print(frequency, 1); // Print the frequency with 1 decimal place
- // Decide which Amateur radio Frequency Band the radio's frequency is on
- String frequencyBand = "";
- if (frequency >= 1.8 && frequency <= 2.0) {
- frequencyBand = "160m";
- } else if (frequency >= 3.5 && frequency <= 4.0) {
- frequencyBand = "80m";
- } else if (frequency >= 7.0 && frequency <= 7.3) {
- frequencyBand = "40m";
- } else if (frequency >= 14.0 && frequency <= 14.35) {
- frequencyBand = "20m";
- } else if (frequency >= 21.0 && frequency <= 21.45) {
- frequencyBand = "15m";
- } else if (frequency >= 28.0 && frequency <= 29.7) {
- frequencyBand = "10m";
- } else {
- frequencyBand = "Unknown Band";
- }
- // Write the radio frequency and frequency band to the LCD display
- lcd.setCursor(0, 1);
- lcd.print("Band: ");
- lcd.print(frequencyBand);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement