Chinmaye
Full Member level 3
Hello,
I am trying to generate a sawtooth waveform using Arduino and DAC 0808. I connected the two checked that the DAC works properly. That is when i make MSB = 1 and rest of the bits =0, Multimeter reads vref/2. I have configured pins 2 to 9 are output pins with 2 being LSB and 9 MSB. I also see that it works fine on serial monitor. Not sure whats wrong with it. Please help.
I am trying to generate a sawtooth waveform using Arduino and DAC 0808. I connected the two checked that the DAC works properly. That is when i make MSB = 1 and rest of the bits =0, Multimeter reads vref/2. I have configured pins 2 to 9 are output pins with 2 being LSB and 9 MSB. I also see that it works fine on serial monitor. Not sure whats wrong with it. Please help.
Code C - [expand] 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 33 34 35 int val; byte mask; void setup() { // put your setup code here, to run once: Serial.begin(9600); for (int i = 2; i < 10; i++) { pinMode(i, OUTPUT); } val = 0; } void loop() { // put your main code here, to run repeatedly: int k =2; for (mask = 00000001; mask>0; mask <<= 1) { //iterate through bit mask if (val & mask){ // if bitwise AND resolves to true digitalWrite(k,HIGH); // send 1 } else{ //if bitwise and resolves to false digitalWrite(k,LOW); // send 0 } k++; } val++; if (val > 255) val = 0; }