Go Down

Topic: binary form in Serial window (Read 560 times) previous topic - next topic

m_lab85

hi all,


i am using the following code DAC from
http://www.youtube.com/watch?v=-hKIXj5dAjc



Code: [Select]
int led = 31;

//1kHz
int sine[] = {2048,2305,2557,2802,3034,3251,3449,3625,3777,3901,3995,4059,4092,4092,4060,3996,3902,3778,3628,3452,3254,3037,2805,2560,2308,2051,1795,1542,1297,1065,847,649,473,321,197,102,37,4,4,35,99,193,316,466,642,839,1056,1288,1533,1785,2041};

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);   
  pinMode(DAC0, OUTPUT);   
}

// the loop routine runs over and over again forever:
void loop() {
  for(int i = 0; i<50;i++){
      if(sine[i]>4095) {
         sine[i]=4095;
         digitalWrite(led, LOW);
     }
    analogWriteResolution(12);
    analogWrite(DAC0, sine[i]);
    delayMicroseconds(14);
  }
}


i want to see the binary form of the sine wave in Serial window. i know there is print() function but i am not sure how to use it.

any help would be greatly appreciated,

m,

garygid

#1
Dec 05, 2013, 02:36 pm Last Edit: Dec 05, 2013, 02:40 pm by garygid Reason: 1
Perhaps...
Code: [Select]

Serial.println(sine[i], HEX) ; // or DEC

in the loop, in the for-I, maybe just print the first
time through the Loop to avoid printing too much?

Serial.begin(115200) ;
in the setup
Cheers, Gary
Due for controlling Electric car charging.
Nissan LEAF - Mini Quick Charge (mQC)

m_lab85

thanks i will try it,

regards,

m

m_lab85


hi

i've tried this function but it gives me HEX. not binary

Serial.println(sine, HEX) ; // or DEC



regards,

M

Gericom

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy