Devices & Components
Arduino Mega 2560 Rev3
Jumper Wires
Speaker: 3W, 4 ohms
Breadboard (generic)
Resistor 10k ohm
Rotary potentiometer (generic)
Project description
Code
Straight Key Oscillator.fzz.ino
arduino
Code practice oscillator for use in amateur radio
1/* 2 This circuit is for a Straight Key Code Practice Oscillator. 3 4 Straight Key (using pushbutton in place of a straight key in this Sketch) 5 6 Sends tone to speaker connected to digital pin 8, 7 when pressing the Straight Key (pushbutton) attached to pin 2. 8 9 The circuit: 10 - Speaker - from pin 8 through potentiometer to speaker to ground 11 - Straight Key (pushbutton) attached to pin 2 from +5V 12 - 10K resistor attached to pin 2 from ground 13 14 created 2018 15 by Jon Garber AC8XU 16 17 This example code is in the public domain. 18 19 */ 20 21// constants won't change. They're used here to set pin numbers: 22const int buttonPin = 2; // the number of the pushbutton pin 23int audio8 = 8; // output audio on pin 8 24int note = 800; // music note/pitch 25 26// variables will change: 27int buttonState = 0; // variable for reading the pushbutton status 28 29void setup() { 30 // initialize the pushbutton pin as an input: 31 pinMode(buttonPin, INPUT); 32 33} 34 35void loop() { 36 // read the state of the pushbutton value: 37 buttonState = digitalRead(buttonPin); 38 39 // check if the pushbutton is pressed. If it is, the buttonState is HIGH: 40 if (buttonState == HIGH) { 41 // turn Speaker on: 42 tone(audio8, note); 43 } else { 44 // turn Speaker off: 45 noTone(audio8); 46 } 47} 48
Straight Key Oscillator.fzz.ino
arduino
Code practice oscillator for use in amateur radio
1/* 2 This circuit is for a Straight Key Code Practice Oscillator. 3 4 Straight Key (using pushbutton in place of a straight key in this Sketch) 5 6 Sends tone to speaker connected to digital pin 8, 7 when pressing the Straight Key (pushbutton) attached to pin 2. 8 9 The circuit: 10 - Speaker - from pin 8 through potentiometer to speaker to ground 11 - Straight Key (pushbutton) attached to pin 2 from +5V 12 - 10K resistor attached to pin 2 from ground 13 14 created 2018 15 by Jon Garber AC8XU 16 17 This example code is in the public domain. 18 19 */ 20 21// constants won't change. They're used here to set pin numbers: 22const int buttonPin = 2; // the number of the pushbutton pin 23int audio8 = 8; // output audio on pin 8 24int note = 800; // music note/pitch 25 26// variables will change: 27int buttonState = 0; // variable for reading the pushbutton status 28 29void setup() { 30 // initialize the pushbutton pin as an input: 31 pinMode(buttonPin, INPUT); 32 33} 34 35void loop() { 36 // read the state of the pushbutton value: 37 buttonState = digitalRead(buttonPin); 38 39 // check if the pushbutton is pressed. If it is, the buttonState is HIGH: 40 if (buttonState == HIGH) { 41 // turn Speaker on: 42 tone(audio8, note); 43 } else { 44 // turn Speaker off: 45 noTone(audio8); 46 } 47} 48
Downloadable files
Straight Key Oscillator
Straight Key Oscillator

Comments
Only logged in users can leave comments