Would someone please help me bridge the gap in analog audio in to PWM out RF transmission? I've interfaced a 104 (.1uF) capacitor with 100/100K voltage divider on 3.5mm input from Android phone. I'm getting about 2.5v on the Serial Port. I think I understand that an analog audio sine wave has to coalesce to square PWM wave. Notes throughout code are things I've tried over the past 2 days.
int audioPin = A0; // positive lead from 3.5mm phone headphone jack; other lead to GND
//int transmitPin = 10; // positive lead to antenna; neg. antenna lead to GND
const byte ANTENNA = 9;
//int val = 8;
void setup() {
Serial.begin(9600);
pinMode(ANTENNA, OUTPUT);
// set up Timer 1
TCCR1A = _BV (COM1A0); // toggle OC1A on Compare Match, Timer Interrupts
TCCR1B = _BV(WGM12) | _BV(CS10); // CTC (clear timer) no prescaler
OCR1A = 14; // 530 kHz
}
void loop() {
int sensorValue = analogRead(audioPin);
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
//val = analogRead(audioPin);
digitalWrite(ANTENNA, voltage);
//analogWrite(ANTENNA, voltage);
}