Friday, December 16, 2011

membuat mesin tetas telur dengan arduino

persiapan :
1 buah mini fan komputer.bole fan yang udah bisa pakai listrik AC
atau pakai fan komputer dgn AC to DC converter
beli trafo 9-12vct 0.5A, 2 bh diode in4001.

 




lampu yang di gunakan lampu pijar 25 watt atau 60 watt
lalu rangkai arduino nya.
logika nya :
jika suhu diatas 37,maka lampu di matikan,
jika suhu di bawah 37,maka lampu di nyalakan.




Wednesday, September 21, 2011

4 digit 7 segmen led

long n = 0;
int x = 100;
int del = 1;

void setup(){
// clearLEDs();
// testLEDs();
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(1, OUTPUT);

}

void loop(){

clearLEDs();
pickDigit(1);
pickNumber((n/x/1000)%10);
delayMicroseconds(del);
clearLEDs();
pickDigit(2);
pickNumber((n/x/100)%10);
delayMicroseconds(del);
clearLEDs();
pickDigit(3);
pickNumber((n/x/10)%10);
delayMicroseconds(del);
clearLEDs();
pickDigit(4);
pickNumber(n/x % 10);
delayMicroseconds(del);
if(n/x > 9999){
n = 0;
delay(5000);
}
else n++;
}

void pickDigit(int x){
digitalWrite(13, LOW); // dig 1
digitalWrite(12, LOW); // dig 2
digitalWrite( 9, LOW); // dig 3
digitalWrite( 8, LOW); // dig 4

switch(x){
case 1: digitalWrite(13, HIGH); break;
case 2: digitalWrite(12, HIGH); break;
case 3: digitalWrite(9, HIGH); break;
case 4: digitalWrite(8, HIGH); break;
}
}

void pickNumber(int x){
switch(x){
case 1: one(); break;
case 2: two(); break;
case 3: three(); break;
case 4: four(); break;
case 5: five(); break;
case 6: six(); break;
case 7: seven(); break;
case 8: eight(); break;
case 9: nine(); break;
default: zero(); break;
}
}

void clearLEDs(){
//digitalWrite(13, HIGH);
// digitalWrite(12, HIGH);
//digitalWrite(9, HIGH);
// digitalWrite(8, HIGH);
digitalWrite( 5, HIGH); // A
digitalWrite( 7, HIGH); // B
digitalWrite( 4, HIGH); // C
digitalWrite(11, HIGH); // D
digitalWrite(10, HIGH); // E
digitalWrite( 3, HIGH); // F
digitalWrite( 6, HIGH); // G
}

void one(){
digitalWrite( 5, HIGH); // A
digitalWrite( 7, LOW); // B
digitalWrite( 4, LOW); // C
digitalWrite(11, HIGH); // D
digitalWrite(10, HIGH); // E
digitalWrite( 3, HIGH); // F
digitalWrite( 6, HIGH); // G
}

void two(){
digitalWrite( 5, LOW); // A
digitalWrite( 7, LOW); // B
digitalWrite( 4, HIGH); // C
digitalWrite(11, LOW); // D
digitalWrite(10, LOW); // E
digitalWrite( 3, HIGH); // F
digitalWrite( 6, LOW); // G
}

void three(){
digitalWrite( 5, LOW); // A
digitalWrite( 7, LOW); // B
digitalWrite( 4, LOW); // C
digitalWrite(11, LOW); // D
digitalWrite(10, HIGH); // E
digitalWrite( 3, HIGH); // F
digitalWrite( 6, LOW); // G
}

void four(){
digitalWrite( 5, HIGH); // A
digitalWrite( 7, LOW); // B
digitalWrite( 4, LOW); // C
digitalWrite(11, HIGH); // D
digitalWrite(10, HIGH); // E
digitalWrite( 3, LOW); // F
digitalWrite( 6, LOW); // G
}

void five(){
digitalWrite( 5, LOW); // A
digitalWrite( 7, HIGH); // B
digitalWrite( 4, LOW); // C
digitalWrite(11, LOW); // D
digitalWrite(10, HIGH); // E
digitalWrite( 3, LOW); // F
digitalWrite( 6, LOW); // G
}

void six(){
digitalWrite( 5, LOW); // A
digitalWrite( 7, HIGH); // B
digitalWrite( 4, LOW); // C
digitalWrite(11, LOW); // D
digitalWrite(10, LOW); // E
digitalWrite( 3, LOW); // F
digitalWrite( 6, LOW); // G
}

void seven(){
digitalWrite( 5, LOW); // A
digitalWrite( 7, LOW); // B
digitalWrite( 4, LOW); // C
digitalWrite(11, HIGH); // D
digitalWrite(10, HIGH); // E
digitalWrite( 3, HIGH); // F
digitalWrite( 6, HIGH); // G
}

void eight(){
digitalWrite( 5, LOW); // A
digitalWrite( 7, LOW); // B
digitalWrite( 4, LOW); // C
digitalWrite(11, LOW); // D
digitalWrite(10, LOW); // E
digitalWrite( 3, LOW); // F
digitalWrite( 6, LOW); // G
}

void nine(){
digitalWrite( 5, LOW); // A
digitalWrite( 7, LOW); // B
digitalWrite( 4, LOW); // C
digitalWrite(11, LOW); // D
digitalWrite(10, HIGH); // E
digitalWrite( 3, LOW); // F
digitalWrite( 6, LOW); // G
}

void zero(){
digitalWrite( 5, LOW); // A
digitalWrite( 7, LOW); // B
digitalWrite( 4, LOW); // C
digitalWrite(11, LOW); // D
digitalWrite(10, LOW); // E
digitalWrite( 3, LOW); // F
digitalWrite( 6, HIGH); // G
}