/* Version 1 10 March,2015 ND6T This source file is under General Public License version 3.0 Control of AD9850 DDS board by Arduino Uno R3 using minimal leads and serial USB control. Waits for USB input while sending a single frequency. */ //Prep for AD9850 #define CLK 10 // Pin 10 : AD9850 clock pin #define FQ 11 // Pin 11 : freq update pin #define DAT 12 // Pin 12 : DATA pin #define RST 13 // Pin 13 - RST #define pulse(pin) {digitalWrite(pin, HIGH); digitalWrite(pin, LOW); } float temp; void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); pinMode(FQ, OUTPUT); pinMode(CLK, OUTPUT); pinMode(DAT, OUTPUT); pinMode(RST, OUTPUT); pulse(RST); pulse(CLK); pulse(FQ); } void loop() { if (temp <= 0) { output (7.2e6);} // Whatever default frequency you wish. // Read the input if it's available. while (Serial.available()> 0) { float frequency= Serial.parseFloat(); temp = frequency; //Confirm input: Serial.print("Output frequency= "); Serial.print(frequency/1e6,6); Serial.println(" MHz."); // Send it to the AD9850 output(frequency); } } void output(float frequency) { long freq = frequency * pow (2,32) /125000000; // Reference clock for (int b=0; b<4; b++, freq >>= 8) shiftOut(DAT,CLK,LSBFIRST,freq); shiftOut(DAT,CLK,LSBFIRST,0); pulse(FQ); }