i write this code for LDR connected with the AT89s52 through the
ADC MCP3208.
i write the below code.
#include<at89s52.h>
#include<stdio.h>
sbit CLK=P1^2;
sbit MISO=P1^3;
sbit MOSI=P1^4;
sbit CS=P1^5;
float read_adc(unsigned int channel)
{ { unsigned int adc_val=0; float temp; char i;
cs=1; clk=1; mosi=1; miso=1;
cs=0; mosi=1; clk=0; msdelay(100); clk=1;
mosi=1; clk=1;
mosi=0; clk=0; msdelay(100); clk=1;
↧