Laboratoriyaning amaliy qismi.
Ushbu model uchun quyidagi dastur mos keladi:
// C++ code
//
int b1 = 0;
int b2 = 0;
int A = 2;
int B3 = 3;
int C4 = 4;
int D5 = 5;
int E6 = 6;
int F7 = 7;
int G8 = 8;
void setup()
{
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode (A,OUTPUT);
pinMode (B3,OUTPUT);
pinMode (C4,OUTPUT);
pinMode (D5,OUTPUT);
pinMode (E6,OUTPUT);
pinMode (F7,OUTPUT);
pinMode (G8,OUTPUT);
}
void loop()
{
b1=digitalRead(9);
b2=digitalRead(10);
Serial.println(b1);
Serial.println(b2);
if(b1==1)
{
digitalWrite(B3,HIGH);
digitalWrite(C4,HIGH);
delay(1000);
digitalWrite(A,LOW);
digitalWrite(D5,LOW);
digitalWrite(E6,LOW);
digitalWrite(F7,LOW);
digitalWrite(G8,LOW);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,HIGH);
digitalWrite(D5,HIGH);
digitalWrite(C4,LOW);
digitalWrite(F7,LOW);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,LOW);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,LOW);
delay(1000);
digitalWrite(A,LOW);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,LOW);
digitalWrite(D5,LOW);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,LOW);
digitalWrite(G8,HIGH);
digitalWrite(E6,LOW);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,LOW);
digitalWrite(G8,HIGH);
digitalWrite(E6,HIGH);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,LOW);
digitalWrite(E6,LOW);
digitalWrite(D5,LOW);
digitalWrite(C4,HIGH);
digitalWrite(F7,LOW);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,HIGH);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,LOW);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
}
if(b2==1)
{
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,LOW);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,HIGH);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,LOW);
digitalWrite(E6,LOW);
digitalWrite(D5,LOW);
digitalWrite(C4,HIGH);
digitalWrite(F7,LOW);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,LOW);
digitalWrite(G8,HIGH);
digitalWrite(E6,HIGH);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,LOW);
digitalWrite(G8,HIGH);
digitalWrite(E6,LOW);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
digitalWrite(A,LOW);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,LOW);
digitalWrite(D5,LOW);
digitalWrite(C4,HIGH);
digitalWrite(F7,HIGH);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,LOW);
digitalWrite(D5,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(F7,LOW);
delay(1000);
digitalWrite(A,HIGH);
digitalWrite(B3,HIGH);
digitalWrite(G8,HIGH);
digitalWrite(E6,HIGH);
digitalWrite(D5,HIGH);
digitalWrite(C4,LOW);
digitalWrite(F7,LOW);
delay(1000);
digitalWrite(B3,HIGH);
digitalWrite(C4,HIGH);
digitalWrite(A,LOW);
digitalWrite(D5,LOW);
digitalWrite(E6,LOW);
digitalWrite(F7,LOW);
digitalWrite(G8,LOW);
delay(1000);
}
}
Xulosa
Men bu laboratoriya ishini bajarish davomida Har xil loyihalarda Arduino yordamida yetti segmentli bitta raqamli indikatorda raqamlarni ko‘rsatishni o’rgandim.
Do'stlaringiz bilan baham: |