Pages: [1]   Go Down
Author Topic: Turn your Arduino into an AM radio transmitter!  (Read 2738 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Online Online
Brattain Member
*****
Karma: 495
Posts: 19031
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This simple project shows how you can make your Arduino into an AM-band transmitter.

Wiring: Plug a wire into pin D9.



Sketch:

Code:
const byte ANTENNA = 9;

void setup()
  {
  // set up Timer 1
  TCCR1A = _BV (COM1A0);  // toggle OC1A on Compare Match
  TCCR1B = _BV(WGM12) | _BV(CS10);   // CTC, no prescaler
  OCR1A =  9;       // compare A register value to 10 (zero relative)
  }  // end of setup

void loop()
  {
  pinMode (ANTENNA, OUTPUT);
  delay (500);
  pinMode (ANTENNA, INPUT);
  delay (300);
  }  // end of loop

Theory: The 16 MHz clock is divided by 10 (that is, 1.6 MHz) and that is used to toggle pin 9 at that rate, giving a frequency of 800 KHz, since one toggle turns the output on, and second toggle turns it off.

If you hold the Arduino near an AM radio tuned to around 800 KHz you should hear a hissing toggling on and off (like Morse code) as the carrier is turned on and off for 0.5 / 0.3 second intervals.
« Last Edit: January 24, 2012, 12:14:53 am by Nick Gammon » Logged


Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13836
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FUN!
what stopped you from implementing a real morse lib into the code ? smiley-wink
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Online Online
Brattain Member
*****
Karma: 495
Posts: 19031
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Trying to keep it simple. smiley

But I'm sure adding Morse into it would be pretty trivial.
Logged


Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice work.

I am going to try it. Just one wire... SIMPLE hook-up... and load the code... you are done...

Thank Nick Gammon
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well the next logical step would be to add in the tone library and allow a audio frequency tone output pin to modulate the timer output pin 'AM carrier frequency', then you would be talking true Amplitude Modulation, AM. However with everything being square wave outputs, don't now how easy it would be to combine these two signal outputs into a single AM output. Needs a little cleaver passive filtering and combining function circuit.

 Lefty
Logged

Pages: [1]   Go Up
Jump to: