Adding code to fm sweep

Good afternoon forum!
This is my first post so allow me to say thank you to all that help in their various ways, I love how forums operate.
So my question is this.
I have built a “ghost radio” using and uno and a tea 5767 FM radio module, using a code found online.
In a later addition the code was upgraded to allow for a 10k potentiometer going to port A0 to allow the code to sweep faster or slower by way of the pot. Myself and a few others on the thread there had noticed that the new code he uploaded was same as original code without sweep function.
He has long since stopped posting, leaving many a little miffed, so I’m wondering if any of you guys are able to insert the code into the files I have?
Also, just looking at the code, i can see gaps in the fm range,example, 90.0 is missing, plus many others, is there a way to get it to sweep all fm channels from 80 to 108? ive been told theres a better way of doing the fm channels code to include all of them (80 to 108) as the one included is rather long winded.
I have included in this post the original files and an image of how to wire, which we have done.
Many thanks guys.
Roy

Spirit_Box (1).ino (9.75 KB)

TEA5767Radio (1).zip (3.97 KB)

royincanada:
. . . using a code found online. . . .
In a later addition the code was upgraded to allow for a 10k potentiometer going to port A0 to allow the code to

Please supply a link. The .ino you have posted file contains a huge number of hard coded frequencies. Don’t you want to load these, say to an EEPROM, by scanning the whole band?

6v6gt:
Please supply a link. The .ino you have posted file contains a huge number of hard coded frequencies. Don't you want to load these, say to an EEPROM, by scanning the whole band?

Do you really want to encourage such superstitious nonsense? I am having problems with 'er indoors because she is being taken in by all this nonsense and will not accept any words of proof about these "spirit boxes" and what they ACTUALLY do.

I call it very dangerous to the hard of thinking.

OK. I was looking at it purely from the point of view of a technical issue with an FM radio module. To me, the application sounded like a Halloween prop or something of that nature. If the OP supplies a link, maybe we learn some more.

6v6gt:
Please supply a link. The .ino you have posted file contains a huge number of hard coded frequencies. Don't you want to load these, say to an EEPROM, by scanning the whole band?

Not sure what this means sir! That's the code we got from online to do this project, and this is supposed to be v2 to include the sweep control via the pot.
Ideally I want it to sweep from 76.0 to 108.0 FM without missing any frequencies, if that makes sense..it just scans through every channel without locking on to one, which this code seems to do. If there's a better way, great I'm all ears, but ultimately I'm just missing the code to control how slow or fast it sweeps.

Yes I get some purple do not believe how this works, or why it works and dangerous is a point of view. Yes tv has glorified what was once a taboo subject and now everyone thinks it's ok to do it, which I'm not really ok with, but having been in this field over 30 years, I know my limitations. I just really enjoy building electronics for this kind of field.

6v6gt:
Please supply a link. The .ino you have posted file contains a huge number of hard coded frequencies. Don't you want to load these, say to an EEPROM, by scanning the whole band?

Here is the original video,

This is the link to add the pot, but even though in the google drive link it says (1) the code is exactly the same as link in video one so pot does not work..
This is the code I need written

Hope this helps
Many thanks guys
Roy

6v6gt:
OK. I was looking at it purely from the point of view of a technical issue with an FM radio module. To me, the application sounded like a Halloween prop or something of that nature. If the OP supplies a link, maybe we learn some more.

Yes, that's quite right.

My objection is that although it might be a bit of fun to those who understand the facts, the uneducated and vulnerable get swept along into believing this nonsense and are mentally disturbed by it. As an example, my wife has now (surreptitiously, she thinks I don't know) been buying these bat detectors etc out of money she doesn't have. She sits there night after night staring at her 'phone watching these ridiculous "ghost hunts" and has now taken out a subscription to watch more of it, even though she has no job and only a small benefit payment.

As an example of the technobabble that they come out with, claiming paranornal activity:

Ni-Cd batteries going flat (in brass monkey weather).

Defocussed insects flying outside the camera's depth of field, reflecting IR as an "orb".

Wooden staircases creaking one step at a time (after somebody previously used it).

Doors that shut in a draught (as if that is unusual).

"Spirit communication"... This one is one of the best...

A wideband radio receiver often tuned to the 60KHz band ( A bat detector amongst other uses of that band) is connected to a frequency selective audio filter. This is then connected to a voice synthesiser with a range of pre-programmed words that are "spoken" according to the filtering. This is then touted as evidence of "ghosts" communicating with the operator.

It makes me absolutely mad to see people who are desperately missing a loved one and those who for whatever reason have not been educated, taken in by these thoughtless charlatans.

It looks like they are now using 88-108MHz because the front ends are easier to find at low prices.

Not sure how this helps with coding a potentiometer, I'm sure there's other places to vent your own beliefs on paranormal things.
Yes tv has given belief to all and sundry that anyone can be an investigator and there are those who try to profit from it, usually using most things you listed as "proof" of how good they are, these are the kind of people that give genuine investigators a bad name.
When you've been doing this a while you factor in every possible way to debunk probably 99% of things that happen.
It starts to get get real when your thrown through a doorway or can actually hear someone talking to you without means of any equipment.

I'm just trying to build a box for my missus as a toy for her to play with when we go out..nothing more, not selling them, not trying to convince others I can talk to their loved ones, most decent investigators will not do personal investigations, that's just plain immoral.

royincanada:
Not sure how this helps with coding a potentiometer, I'm sure there's other places to vent your own beliefs on
It starts to get get real when your thrown through a doorway or can actually hear someone talking to you without means of any equipment.

Bless.

The first REAL scientist that shows proof of any these things will prompt my full and public apology. Until then I will be doing my best to prevent this silly superstitious nonsense from getting any publicity. Once again, it preys on the vulnerable and uneducated who generally refuse to listen to any simple scientific evidence once caught up in it.

OK. Without going too deeply into the superstitious side of this, what is this potentiometer supposed to do ? Change the period of one scan of the whole band from X (minimum) to Y (maximum) and I guess linear ?

Yeah, not getting into personal beliefs etc, theres other places for this to be debated.

As for the pot, the pot is there to change the sweep rate, from slower to faster. if the pot is in its middle position, then its sweeping through the stations at whatever rate the arduino code is telling the fm module to do (or fm telling arduino, not sure), so lets say for example each sweep is 1/4 second long before it scans to next channel.
Turn the pot left, it decreses the sweep rate, all the way down to say, for example, 2 seconds between the next sweep. turn it to the right, it sweeps faster, say, up to 750milliseconds per sweep.
Get me?

I’ve just looked at the zip file :

.h

Licence stuff . . .

#include <Wire.h>

#ifndef TEA5767Radio_h
#define TEA5767Radio_h


class TEA5767Radio
{
private:
	int _address;

public:
  TEA5767Radio();
  TEA5767Radio(int address);
  void setFrequency(float frequency);
  void setFrequency();
};


#endif

.cpp

Licence stuff . . .

#include <Arduino.h>
#include <TEA5767Radio.h>

TEA5767Radio::TEA5767Radio(int address)
{
  _address = address;
}

TEA5767Radio::TEA5767Radio()
{
  _address = 0x60;
}


void TEA5767Radio::setFrequency(float frequency)
{
  	unsigned int frequencyB = 4 * (frequency * 1000000 + 225000) / 32768; 
	byte frequencyH = frequencyB >> 8;
	byte frequencyL = frequencyB & 0XFF;
	Wire.beginTransmission(_address); 
	Wire.write(frequencyH);
	Wire.write(frequencyL);
	Wire.write(0xB0);
	Wire.write(0x10);
	Wire.write(0x00);
	Wire.endTransmission();
	delay(100);  
}

.ino

#include <TEA5767Radio.h>

#include <Wire.h>


int led=13;
TEA5767Radio radio = TEA5767Radio();



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


Serial.println(1);
delay(1);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(104.7);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(88.1);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(88.3);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(88.1);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(88.7);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(88.9);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(89.1);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(89.1);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(89.3);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(89.1);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
radio.setFrequency(89.7);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);
. . .
and stacks more of this
. . .
radio.setFrequency(108.1);
digitalWrite(led,HIGH);
delay(1);
digitalWrite(led,LOW);
delay(1);

}

You have understood that it does not scan the entire band, it simply picks out predefined frequencies and delays 2 millisecond between selection and repeats the whole thing endlessly ?

If you want to vary the rate at which it changes channel with a 10k pot, in principle you wire the wiper to an analogue pin, say A0, and wire the other two pins between between the power rails. You use analogRead( ) and get a value between 0 and 1023. It is this result which you must map to the desired period between channel changes. If you continue to use a whole series of delay() statements to control this period, the pot will appear unresponsive unless you read it between each channel change. Ideally you’d restructure the whole thing to avoid huge amounts of repeated code and eliminate the delay() statements.

Hey.
Yeah, ok, your right in the pot placement, it is wired to a0, with +- at the power rails.
After that im a little lost.
So the codes youve added will do the job?
sorry for my total newbness
thank you..
Roy

I have not added any code. I have simply presented your code so it is more visible.
But back to my question about how it should work with reference to how it currently works.

From the supplied .ino file, it is clear that the program steps through a series of channels and does this in a continuous loop.
104.7
88.1
88.3
88.7
88.1
Etc.

There is a total delay of 2ms and the led flashes once between each channel change.
It can be made to systematically scan an entire band say 80.0, 80.1, 80.2 . . .108.0 assuming that full range is supported. It can also be made to pick random channels. However, I wonder if the original channel list was deliberately chosen to include channels which had a strong signal to avoid periods of silence etc.

Anyway, trying to interpret your example, you’d want the maximum period between channel changes to be 16 milliseconds and the minimum to be 250 microseconds?

Hi.
Yeah, I just put in known frequencies.
In an ideal world is like to find a way to eliminate known radio station frequencies, leaving ones advice and below the ones used in North America so there’s no false positives, I’ve had a radio station come on with one word at exactly the same time as a question was asked giving the right response, if that makes sense, so was quickly debunked.
But yeah, those sweep ranges you mention would be perfect, but if there’s a way to go faster through than 250, I’ll take it. I have one device that does 250, 450, 650, faster would be great!

This goes systematically through the entire band 88.0 to 108.0 with increments of 0.1. I have not incorporated a potentiometer, nor have I tested it.

#include <TEA5767Radio.h>   // was <  >

#include <Wire.h>


int led = 13;
TEA5767Radio radio = TEA5767Radio();



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

}
void loop()
{
  Serial.println(1);
  digitalWrite(led, HIGH);

  // scan 88.00 to 108.00 with increments of 0.1
  for ( uint32_t chanx100 = 8800 ; chanx100 < 10800 ; chanx100 += 10 ) {
    radio.setFrequency( (float)( chanx100 / 100 ) );
    delayMicroseconds( 250 ) ;  // note:the .cpp file has a delay of 100ms anyway per channel change
  }
  digitalWrite(led, LOW);
  delay( 100 ) ;
}

Thank you so so much.
I will test this code when i get back.
Sorry for late reply, took a late vacation..
Thanks
Roy