Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 /*
Arduino CW oscillator by ESC crasci
*/
#include "pitches.h"
int buttonState = 0 ;
const int threshold = 10 ; // minimum reading of the sensors that generates a note
const int buttonPin = 4 ;
const int ledPin = 5 ;
// notes to play, corresponding to the 3 sensors:
int notes[] = {
NOTE_A4
};
void setup () {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop () {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// play the note corresponding to this sensor:
tone(8 , notes[0 ], 20 );
digitalWrite(5 ,HIGH);
}
else {
digitalWrite(5 ,LOW);
}
}
Scheme (PDF,Image):
SVG Image created as oscillator.svg date 2023/09/12 18:12:32
Image generated by Eeschema-SVG
1
1
2
2
3
3
4
4
1
1
2
2
3
3
4
4
A
A
B
B
C
C
A
A
B
B
C
C
Date: 01/05/2023
Date: 01/05/2023
KiCad E.D.A. kicad (7.0.0)
KiCad E.D.A. kicad (7.0.0)
Rev: 2
Rev: 2
Size: A5
Size: A5
Id: 1/1
Id: 1/1
Title: DIY CW OSCILLATOR SCHEME-ESC crasci
Title: DIY CW OSCILLATOR SCHEME-ESC crasci
File: oscillator.kicad_sch
File: oscillator.kicad_sch
Sheet: /
Sheet: /
ESC crasci
ESC crasci
Not to be distributed without prior permission.
Not to be distributed without prior permission.
esccrasci.in
esccrasci.in
A1
A1
10
10
A2
A2
11
11
A3
A3
12
12
SDA/A4
SDA/A4
13
13
SCL/A5
SCL/A5
14
14
D0/RX
D0/RX
15
15
D1/TX
D1/TX
16
16
D2
D2
17
17
D3
D3
18
18
D4
D4
19
19
IOREF
IOREF
2
2
D5
D5
20
20
D6
D6
21
21
D7
D7
22
22
D8
D8
23
23
D9
D9
24
24
D10
D10
25
25
D11
D11
26
26
D12
D12
27
27
D13
D13
28
28
GND
GND
29
29
~{RESET}
~{RESET}
3
3
AREF
AREF
30
30
SDA/A4
SDA/A4
31
31
SCL/A5
SCL/A5
32
32
3V3
3V3
4
4
+5V
+5V
5
5
GND
GND
6
6
GND
GND
7
7
VIN
VIN
8
8
A0
A0
9
9
A1
A1
Arduino_UNO_R3
Arduino_UNO_R3
SW1
SW1
SW_Push
SW_Push
10K
10K
1
1
2
2
J1
J1
Jack-DC
Jack-DC
1
1
2
2
LS1
LS1
Speaker
Speaker
SW
SW
SW
SW
Circuit
Circuit
NOTE: CONNECT SPEAKER TO PIN 8.
NOTE: CONNECT SPEAKER TO PIN 8.
THE CW SWITCH TO PIN 4
THE CW SWITCH TO PIN 4
CAN BE USED WITH ANY ARDUINO.
CAN BE USED WITH ANY ARDUINO.
SW1
SW1
SW_Push
SW_Push
10K
10K
PDF:
VIDEO
RESOURCES :
Pin 8: Speaker (10K resistor to be added to ground to prevent debounce)
pin 4: Button (use key of choice)
Use jacks of choice to connect all devices to the main board. I have used female 3.4mm headphone jack sockets. It’s completely up to you!
Purchase links: ( Not Affiliate)
Stereo Socket 3.5mm PCB Mount SMD [5543] : Sunrom Electronics
Enclosure 70x45x18mm Black [4795] : Sunrom Electronics
10K CFR 1/4 0.25 Watt Resistor Through Hole [4036] : Sunrom Electronics
Arduino Pro Mini 5V – QuartzComponents
Pitches.h library: Play a Melody using the tone() function | Arduino
Leave a Reply