Found the resistor value with own program

Selasa, 13 Desember 2011


Now, we will make the program which can know the value of resistor with reading the colors of resistor. This method is very simple, we just see the color, and follow the formula to find the value. This table is the value of the resistor's color in the formula.


How to get the value :
- The first color ring is the first bit,
- The second color ring is the second bit,
- The third color (Multiplier) in 4 rings, Bit 3 rd to 5 rings
- the 4th color is a tolerance in 4 ring, for multiplier in 5 ring
the 5th color is a tolerance in 5 ring
5 ring ----> c1c2c3 x 10c4
4 ring ---->c1c2 x 10c3

And This is the source code of program :
#include
#include#includestruct resistor{
int nilai, toleransi;
char warna[15];
};void main(){
int i, kali=1, y=0;
int tampung, input;
char lagi[2];
float toleransi, hasil=0;
struct resistor resistor1[13] = { {0,0,"Hitam"},
{1,1,"Cokelat"},
{2,2,"Merah"},
{3,0,"Jingga"},
{4,0,"Kuning"},
{5,0,"Hijau"},
{6,0,"Biru"},
{7,0,"Ungu"},
{8,0,"Abu-Abu"},
{9,0,"Putih"},
{0,5,"Perak"},
{0,10,"Emas"},
{0,20,"Tanpa Warna"}};
printf("Berikut Data Warna : \n");
for(i=0;i printf("%d. %s\n",i+1,resistor1[i].warna);
}
while(y==0){
kali = 1;
printf("\nBerapa Jumlah Cincin Resistor (4/5) ? ");
scanf("%d",&input);for(i=0;iprintf("Masukkan Cincin ke-%d = ",i+1); scanf("%d", &tampung);
if(tampung13){ i--; printf("INPUTAN SALAH!!!\n"); continue;}
if(input==4){
if(i==2) hasil*=pow(10,tampung);
else if(i }
else if(input==5){
if(i==3) hasil *= pow(10,tampung);
else if(i }
kali*=10;}
toleransi = (hasil*tampung)/100;
printf("Nilai Resistor = %.0f, toleransi = %.3f, range = %.3f-%.3f\n",hasil, toleransi, hasil-toleransi, hasil+toleransi);
printf("Apa ada lagi(y/t) ?");
scanf("%s",lagi);
if(strcmp(lagi,"t")==0 || strcmp(lagi,"T")==0) y=1;
}
}
This is the ScreenShoot of Program :

0 komentar:

Posting Komentar

 
 
 

Label

Label