Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Useing potentiomete...
 
Share:
Notifications
Clear all

[Solved] Useing potentiometer to adjust sweep on fm

5 Posts
2 Users
0 Likes
1,461 Views
(@royincanada)
Active Member
Joined: 4 years ago
Posts: 3
Topic starter  

Hi all.

Allow me to say hi and that i'm truly grateful for any help i can receive, as i am totally confused.

I have built a "ghost radio" using an uno and tea5767 fm module.

I want the code to sweep through all the frequencies so it doesn't lock onto a channel, repetitively.

Id LIKE it to pick them at random, between 74 and 108fm but that can be done later, right now im struggling with the potentiometer.

I want to use a 10k pot wired into a0 so that i can adjust the speed pf the sweep from, say 1 second between sweeps at its lowest and 700 milliseconds at its fastest.

I'm not sure why the code refuses to compile, so i'm asking for any help i can get.

Many thanks

Roy

This topic was modified 4 years ago by royincanada

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2677
 

Hi Royincanada! 

Welcome to the forum!

Unfortunately, I have zero experience with the Tea5767 radio module, but maybe I can help with your code.
Could you post the code here? And the error message you're getting?


   
ReplyQuote
(@royincanada)
Active Member
Joined: 4 years ago
Posts: 3
Topic starter  

@hans

this is the errors.

G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '8.0e+1' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
const byte stationsList[] = {80.0, 80.1, 80.2, 80.3, 80.4, 80.5, 80.6, 80.7, 80.8, 80.9, 81.0, 81.1, 81.2, 81.3, 81.4, 81.5, 81.6, 81.7, 81.8, 81.9, 82.0, 82.1, 82.2, 82.3, 82.4, 82.5, 82.6, 82.7, 82.8, 82.9, 83.0, 83.1, 83.2, 83.3, 83.4, 83.5, 83.6, 83.7, 83.8, 83.9, 84.0, 84.1, 84.2, 84.3, 84.4, 84.5, 84.6, 84.7, 84.8, 84.9, 85.0, 85.1, 85.2, 85.3, 85.4, 85.5, 85.6, 85.7, 85.8, 85.9, 86.0, 86.1, 86.2, 86.3, 86.4, 86.5, 86.6, 86.7, 86.8, 86.9, 87.0, 87.1, 87.2, 87.3, 87.4, 87.5, 87.6, 87.8, 87.9, 88.0, 88.1, 88.2, 88.3, 88.4, 88.5, 88.6, 88.7, 88.8, 88.9, 89.0, 89.1, 89.2, 89.3, 89.4, 89.5, 89.6, 89.7, 89.8, 89.9, 90.0, 90.1, 90.2, 90.3, 90.4, 90.5, 90.6, 90.7, 90.8, 90.9, 91.0, 91.1, 91.2, 91.3, 91.4, 91.5, 91.6, 91.7, 91.8, 91.9, 92.0, 92.1, 92.2, 92.3, 92.4, 92.5, 92.6, 92.7, 92.8, 92.9, 93.0, 93.1, 93.2, 93.3, 93.4, 93.5, 93.6, 93.7, 93.8, 93.9, 94.0, 94.1, 94.2, 94.3, 94.4, 94.5, 94.6, 94.7, 94.8, 94.9, 95.0, 95.1, 95.2, 95.3, 95.4, 95.5, 95.6, 95.7, 95.8, 95.9, 96.0, 96.1, 96.2, 96.3, 96.4, 96.5, 96.6, 96.7, 96.8, 96.9, 97.0, 97.1, 97.2, 97.3, 97.4, 97.5, 97.6, 97.8, 97.9, 98.0, 98.1, 98.2, 98.3, 98.4, 98.5, 98.6, 98.7, 98.8, 98.9, 99.0, 99.1, 99.2, 99.3, 99.4, 99.5, 99.6, 99.7, 99.8, 99.9, 100.0, 100.1, 100.2, 100.3, 100.4, 100.5, 100.6, 100.7, 100.8, 100.9, 101.0, 101.1, 101.2, 101.3, 101.4, 101.5, 101.6, 101.7, 101.8, 101.9, 102.0, 102.1, 102.2, 102.3, 102.4, 102.5, 102.6, 102.7, 102.8, 102.9, 103.0, 103.1, 103.2, 103.3, 103.4, 103.5, 103.6, 103.7, 103.8, 103.9, 104.0, 104.1, 104.2, 104.3, 104.4, 104.5, 104.6, 104.7, 104.8, 104.9, 105.0, 105.1, 105.2, 105.3, 105.4, 105.5, 105.6, 105.7, 105.8, 105.9, 106.0, 106.1, 106.2, 106.3, 106.4, 106.5, 106.6, 106.7, 106.8, 106.9, 107.0, 107.1, 107.2, 107.3, 107.4, 107.5, 107.6, 107.7, 107.8, 107.9, 108.0}; // fill in your frequencies
^
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '8.00999985e+1' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '8.01999969e+1' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '8.03000031e+1' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '8.04000015e+1' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '8.05e+1' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

...
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '1.07599998e+2' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '1.07699997e+2' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '1.07800003e+2' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '1.07900002e+2' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
G:\Arduino sweep radio\Spirit_Box\v68rvrlftqsiuoua\fm\fm\fm.ino:10:1783: warning: narrowing conversion of '1.08e+2' from 'double' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
Sketch uses 5026 bytes (15%) of program storage space. Maximum is 32256 bytes.
Global variables use 506 bytes (24%) of dynamic memory, leaving 1542 bytes for local variables. Maximum is 2048 bytes.

 

those are the errors.

Ill post code in next reply


   
ReplyQuote
(@royincanada)
Active Member
Joined: 4 years ago
Posts: 3
Topic starter  

@hans

heres the code.

This is the fm tab

#include "TEA5767.h"

#include <Wire.h>

const byte led = 13;
const byte pot = A0; // your potentiometer goes to analog A0

const byte stationsList[] = {80.0, 80.1, 80.2, 80.3, 80.4, 80.5, 80.6, 80.7, 80.8, 80.9, 81.0, 81.1, 81.2, 81.3, 81.4, 81.5, 81.6, 81.7, 81.8, 81.9, 82.0, 82.1, 82.2, 82.3, 82.4, 82.5, 82.6, 82.7, 82.8, 82.9, 83.0, 83.1, 83.2, 83.3, 83.4, 83.5, 83.6, 83.7, 83.8, 83.9, 84.0, 84.1, 84.2, 84.3, 84.4, 84.5, 84.6, 84.7, 84.8, 84.9, 85.0, 85.1, 85.2, 85.3, 85.4, 85.5, 85.6, 85.7, 85.8, 85.9, 86.0, 86.1, 86.2, 86.3, 86.4, 86.5, 86.6, 86.7, 86.8, 86.9, 87.0, 87.1, 87.2, 87.3, 87.4, 87.5, 87.6, 87.8, 87.9, 88.0, 88.1, 88.2, 88.3, 88.4, 88.5, 88.6, 88.7, 88.8, 88.9, 89.0, 89.1, 89.2, 89.3, 89.4, 89.5, 89.6, 89.7, 89.8, 89.9, 90.0, 90.1, 90.2, 90.3, 90.4, 90.5, 90.6, 90.7, 90.8, 90.9, 91.0, 91.1, 91.2, 91.3, 91.4, 91.5, 91.6, 91.7, 91.8, 91.9, 92.0, 92.1, 92.2, 92.3, 92.4, 92.5, 92.6, 92.7, 92.8, 92.9, 93.0, 93.1, 93.2, 93.3, 93.4, 93.5, 93.6, 93.7, 93.8, 93.9, 94.0, 94.1, 94.2, 94.3, 94.4, 94.5, 94.6, 94.7, 94.8, 94.9, 95.0, 95.1, 95.2, 95.3, 95.4, 95.5, 95.6, 95.7, 95.8, 95.9, 96.0, 96.1, 96.2, 96.3, 96.4, 96.5, 96.6, 96.7, 96.8, 96.9, 97.0, 97.1, 97.2, 97.3, 97.4, 97.5, 97.6, 97.8, 97.9, 98.0, 98.1, 98.2, 98.3, 98.4, 98.5, 98.6, 98.7, 98.8, 98.9, 99.0, 99.1, 99.2, 99.3, 99.4, 99.5, 99.6, 99.7, 99.8, 99.9, 100.0, 100.1, 100.2, 100.3, 100.4, 100.5, 100.6, 100.7, 100.8, 100.9, 101.0, 101.1, 101.2, 101.3, 101.4, 101.5, 101.6, 101.7, 101.8, 101.9, 102.0, 102.1, 102.2, 102.3, 102.4, 102.5, 102.6, 102.7, 102.8, 102.9, 103.0, 103.1, 103.2, 103.3, 103.4, 103.5, 103.6, 103.7, 103.8, 103.9, 104.0, 104.1, 104.2, 104.3, 104.4, 104.5, 104.6, 104.7, 104.8, 104.9, 105.0, 105.1, 105.2, 105.3, 105.4, 105.5, 105.6, 105.7, 105.8, 105.9, 106.0, 106.1, 106.2, 106.3, 106.4, 106.5, 106.6, 106.7, 106.8, 106.9, 107.0, 107.1, 107.2, 107.3, 107.4, 107.5, 107.6, 107.7, 107.8, 107.9, 108.0}; // fill in your frequencies

TEA5767 radio = TEA5767();

int stationsNum = 0;

void setup() {
Wire.begin();
Serial.begin(9600);

stationsNum = sizeof(stationsList) / sizeof(stationsList[0]);
}

// radio.setFrequency(104.7);

void loop() {
static uint32_t prev;

if ( millis() - prev < 100 ) {
return;
}
prev = millis();

// doing it

static int prevRead;
int currentRead;
currentRead = analogRead(pot);

if ( abs(currentRead - prevRead) > 10 ) { //changes detected
prevRead = currentRead;

int freq = map(currentRead, 5, 1020, 0, stationsNum);
radio.setFrequency(freq);
}

}

 

 

There is also two more tabs with code, tea5756.cpp and tea5767.h

do you need those posted also?

 

Many thanksRoy

 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2677
 

The first thing I noticed is that you create an array of byte, but you're populating it with float numbers.

const byte stationsList[] = {80.0, 80.1, 80.2, 80.3, ...

A byte only allows integer numbers, so numbers without a decimal point.

Try changing it to:

const float stationsList[] = {80.0, 80.1, 80.2, 80.3, ...

That should take care of the "narrowing conversion" errors.


   
ReplyQuote
Share: