Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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 36 37 38 39 40 41 42 43 44 45 46 #include<reg51.h> #define input P0 //Input port to read the values of ADc #define output P2 // Output port, connected to LED's. sbit wr= P1^1; // Write pin. It is used to start the conversion. sbit rd= P1^0; // Read pin. It is used to extract the data from internal register to the output pins of ADC. sbit intr= P1^2; // Interrupt pin. This is used to indicate the end of conversion. It goes low when conversion is complete. void delay(unsigned int msec ) // The delay function provides delay in msec. { int i,j ; for(i=0;i<msec;i++) for(j=0; j<1275; j++); } void Bin2Dec(char n) { int bin,n,r,s=0,i; n=bin; for(i=0;n!=0;i++) { r=n%10; s=s+r*(int)pow(2,i); n=n/10; } s=output // s is havin decimal value now } void adc() // Function to read the values from ADC and display on the LED's. { rd=1; wr=0; delay(1); wr=1; while(intr==1); rd=0; output=input; delay(1); intr=1; } void main() { input=0xff; // Declare port 0 as input port. while(1) { adc(); } }
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 void Dec2Hex() { int n,r[10],i; printf("Enter a number to get its hexadecimal equivalent\n"); scanf("%d",&n); for(i=0;n!=0;i++) { r[i]=n%16; n=n/16; } i--; for(;i>=0;i--) { if(r[i]==10) printf("A"); else if(r[i]==11) printf("B"); else if(r[i]==12) printf("C"); else if(r[i]==13) printf("D"); else if(r[i]==14) printf("E"); else if(r[i]==15) printf("F"); else printf("%d",r[i]); } printf("\n"); }
I need for pic 16f877 controller? ccs compiler
Want to display in led only. 8 led connected to port d...