When preparing the Blue Bridge Cup , about 8591 What about this chip , I think there are three main aspects of learning , One is an adjustable resistor , The other is photoresist , The last one is DAC Analog voltage output
Then for 8591 What about this chip , Mainly 4 individual ADC as well as 1 individual DAC, Here is DAC How to use .
#include"reg52.h"
#include"iic.h"
sbit s1=P3^0;
sbit s2=P3^1;
sbit s3=P3^2;
sbit s4=P3^3;
unsigned int dat2=0;
unsigned char code tab[18]=
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,
0x88,0x80,0xc6,0xc0,0x86,0x8e,0xbf,0x7f};
void delay(unsigned int t)
{
while(t–);
}
void PCF8591DAC(unsigned char dat)
{
IIC_Start();
IIC_SendByte(0x90);
IIC_WaitAck();
IIC_SendByte(0x40);
IIC_WaitAck();
IIC_SendByte(dat);
IIC_WaitAck();
IIC_Stop();
}
void key()
{
if(s1=0)
{
delay(500);
if(s1==0)
{
dat2=dat2+51;
if(dat2==306)
{
dat2=0;
}
while(s1=0);
}
}
}
void main()
{
while(1)
{
key();
PCF8591DAC(dat2);
}
}
* List item
Technology