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.
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 maskif(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;}