Kumpulan Coding Program Arduino.docx

  • Uploaded by: Ashabul Khaffi
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Kumpulan Coding Program Arduino.docx as PDF for free.

More details

  • Words: 678
  • Pages: 5
1 SAKLAR 1 LED

digitalWrite (10,LOW); // LED 2 Padam } if (digitalRead (8)== 1)// Jika Saklar 2 OFF

void setup() { pinMode(2,OUTPUT);

{ digitalWrite (10,HIGH); // LED 2 Menyala

pinMode(10,OUTPUT);} void loop() { if (digitalRead (8)== 0)

} }

{ digitalWrite (10,LOW); SWITCH-CASE 7 SEG.4 KONDISI

} if (digitalRead (8)== 1)

// commen anode Arduino pin : 2,3,4,5,6,7,8,9 byte seven_seg_digits[10][8]= {

{

{ 0,0,0,0,0,0,1,1 }, // = 0

digitalWrite (10,HIGH);}

{ 1,0,0,1,1,1,1,1 }, // = 1

}

{ 0,0,1,0,0,1,0,1 }, // = 2 2 SAKLAR 2 LED 4 KONDISI

{ 0,0,0,0,1,1,0,1 }, // = 3

void setup()

{ 1,0,0,1,1,0,0,1 }, // = 4

{ pinMode(1,INPUT); // Saklar 1 PULL DOWN

{ 0,1,0,0,1,0,0,1 }, // = 5

pinMode(8,INPUT); // Saklar 2 PULL UP

{ 0,1,0,0,0,0,0,1 }, // = 6

pinMode(2,OUTPUT);// LED 1 PULL DOWN

{ 0,0,0,1,1,1,1,1 }, // = 7

pinMode(10,OUTPUT);// LED 2 PULL UP

{ 0,0,0,0,0,0,0,1 }, // = 8

}

{ 0,0,0,0,1,0,0,1 }, // = 9

void loop()

};

{

void setup()

if (digitalRead (1) == 0) // jika Saklar 1 OFF

{ pinMode(10, INPUT); // SAKLAR 1

{ digitalWrite (2,LOW); // LED 1 Menyala

pinMode(11, INPUT); // SAKLAR 2

}

pinMode(2, OUTPUT);

if (digitalRead (1) == 1) // Jika Saklar 1 ON

pinMode(3, OUTPUT);

{

pinMode(4, OUTPUT); digitalWrite (2,HIGH); // LED 1 Padam

pinMode(5, OUTPUT);

}

pinMode(6, OUTPUT);

if (digitalRead (8)== 0) // Jika Saklar 2 ON

pinMode(7, OUTPUT);

{

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

digitalWrite(5,LOW);

}

digitalWrite(6,LOW);

void loop()

digitalWrite(7,LOW);

{

digitalWrite(8,LOW);

switch (digitalRead (10)==1 &&digitalRead (11)==1) // SAKLAR 1 DAN 2 OFF

digitalWrite(9,HIGH);

{

break;

// Number 8

case 2:

case 1:

digitalWrite(2,LOW);

digitalWrite(2,LOW);

digitalWrite(3,LOW);

digitalWrite(3,LOW);

digitalWrite(4,LOW);

digitalWrite(4,LOW);

digitalWrite(5,LOW);

digitalWrite(5,LOW);

digitalWrite(6,LOW);

digitalWrite(6,LOW);

digitalWrite(7,LOW);

digitalWrite(7,LOW);

digitalWrite(8,LOW);

digitalWrite(8,HIGH);

digitalWrite(9,HIGH);

digitalWrite(9,HIGH); break;

// Number 0

case 2:

break;

// Number 8

}

digitalWrite(2,LOW);

switch (digitalRead (10)== 0&& digitalRead (11)==1) // SAKLAR 1 ON,SAKLAR 2 0FF

digitalWrite(3,LOW);

{

digitalWrite(4,LOW);

case 1:

digitalWrite(5,LOW);

digitalWrite(2,LOW);

digitalWrite(6,LOW);

digitalWrite(3,LOW);

digitalWrite(7,LOW);

digitalWrite(4,LOW);

digitalWrite(8,HIGH);

digitalWrite(5,LOW);

digitalWrite(9,HIGH);

digitalWrite(6,LOW);

break;

digitalWrite(7,LOW);

// Number 0

}

digitalWrite(8,HIGH);

switch (digitalRead (10)==0 &&digitalRead (11)==0)//SAKLAR 1 DAN 2 ON {

digitalWrite(9,HIGH); break;

// Number 0

case 2:

case 1: digitalWrite(2,LOW); digitalWrite(3,LOW); digitalWrite(4,LOW);

digitalWrite(2,HIGH); digitalWrite(3,LOW); digitalWrite(4,LOW);

digitalWrite(5,HIGH);

2 SAKLAR 4 KONDISI LCD

digitalWrite(6,HIGH);

#include

digitalWrite(7,HIGH);

LiquidCrystal lcd(7,6,5,4,3,2);

digitalWrite(8,HIGH);

int count=0;

digitalWrite(9,HIGH);

void setup() {

break;

// Number 1

lcd.begin(16,2);

}

pinMode (8,INPUT);

switch (digitalRead (10)== 1&& digitalRead (11)==0) // SAKLAR 1 OFF,SAKLAR 2 0N

pinMode (9,INPUT); pinMode (8,HIGH);

{

pinMode (9,HIGH); digitalWrite(2,LOW); digitalWrite(3,LOW); digitalWrite(4,LOW);

} void loop() {

digitalWrite(5,LOW);

if (digitalRead (8)==0&&digitalRead (9)==0)

digitalWrite(6,LOW);

{lcd.setCursor (0,0);

digitalWrite(7,LOW);

lcd.print("42116001");

digitalWrite(8,HIGH);

lcd.setCursor (0,1);

digitalWrite(9,HIGH); break;

lcd.print ("42116009");

// Number 0

delay(300);

case 2:

lcd.clear();

digitalWrite(2,LOW); digitalWrite(3,LOW);

} if (digitalRead (8)==1&&digitalRead (9)==1)

digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,HIGH); digitalWrite(7,LOW); digitalWrite(8,LOW); digitalWrite(9,HIGH); break; } }

// Number 9

{lcd.setCursor (0,0); lcd.print ("MUH.IBNU KHAIR"); lcd.setCursor (0,1); lcd.print ("ASH.KHAFFI"); delay(300); lcd.clear(); } if (digitalRead (8)==1&&digitalRead (9)==0) {lcd.setCursor (0,0); lcd.print ("COUNTER UP"); count++; if(count>=100)

count=100;

{

lcd.setCursor (0,1);

digitalWrite(5,LOW);

lcd.print(count);

digitalWrite(6,HIGH);

delay(5);

digitalWrite(7,HIGH);

lcd.clear();

digitalWrite(7,HIGH);

}

if (digitalRead (1)==0) if (digitalRead (8)==0&&digitalRead (9)==1)

{lcd.setCursor (0,0);

{lcd.setCursor (0,0);

lcd.print("7");

lcd.print ("COUNTER DOWN");

}

count--;

if (digitalRead (2)==0)

if(count<0)

{lcd.setCursor (1,0);

count=0;

lcd.print("8");

lcd.setCursor (0,1);

lcd.clear();

lcd.print(count);

}

delay(5);

if (digitalRead (3)==0)

lcd.clear();

{lcd.setCursor (2,0);

}

lcd.print("9");

}

lcd.clear(); } if (digitalRead (4)==0)

KEY PAD TAMPILAN KALKULATOR

{lcd.setCursor (3,0);

#include

lcd.print("/");

LiquidCrystal lcd(0,9,10,11,12,13);

lcd.clear();

void setup() {

}

pinMode (1,INPUT);

{

pinMode (2,INPUT);

digitalWrite(5,HIGH);

pinMode (3,INPUT);

digitalWrite(6,LOW);

pinMode (4,INPUT);

digitalWrite(7,HIGH);

pinMode (5,OUTPUT);

digitalWrite(7,HIGH);

pinMode (6,OUTPUT);

if (digitalRead (1)==0)

pinMode (7,OUTPUT);

{lcd.setCursor (0,1);

pinMode (8,OUTPUT);

lcd.print("4");

}

lcd.clear();

void loop()

}

if (digitalRead (2)==0)

}

{lcd.setCursor (1,1);

if (digitalRead (4)==0)

lcd.print("5");

{lcd.setCursor (3,2);

lcd.clear();

lcd.print("+");

}

lcd.clear();

if (digitalRead (3)==0)

}

{lcd.setCursor (2,1);

}

lcd.print("6");

{

lcd.clear();

digitalWrite(5,HIGH);

}

digitalWrite(6,HIGH);

if (digitalRead (4)==0)

digitalWrite(7,HIGH);

{lcd.setCursor (3,1);

digitalWrite(7,LOW);

lcd.print("X");

if (digitalRead (1)==0)

lcd.clear();

{lcd.setCursor (0,3);

}

lcd.print("ON");

}

lcd.clear();

{

}

digitalWrite(5,HIGH);

if (digitalRead (2)==0)

digitalWrite(6,HIGH);

{lcd.setCursor (1,3);

digitalWrite(7,LOW);

lcd.print("0");

digitalWrite(7,HIGH);

lcd.clear();

if (digitalRead (1)==0)

}

{lcd.setCursor (0,2);

if (digitalRead (3)==0)

lcd.print("1");

{lcd.setCursor (2,3);

}

lcd.print("=");

if (digitalRead (2)==0)

lcd.clear();

{lcd.setCursor (1,2);

}

lcd.print("2");

if (digitalRead (4)==0)

lcd.clear();

{lcd.setCursor (3,3);

}

lcd.print("-");

if (digitalRead (3)==0)

lcd.clear();

{lcd.setCursor (2,2);

}

lcd.print("3");

}

lcd.clear();

}

Related Documents

Coding
December 2019 22
Coding
July 2020 13
Coding
November 2019 26
Coding
April 2020 13

More Documents from ""

Ayo.docx
April 2020 11
03. Kata Pengantar.docx
April 2020 14
Ashabul.docx
April 2020 11