top of page

POTENTIOMETER LIGHT CODE:

const int Yellow_Led_Pin = 3; // הגדרת מנורה לפי המקור אליו הוא מחובר

const int Green_Led_Pin = 4;

const int White_Led_Pin = 5;

const int pot_pin= A0; //הגדרת פטנציומטר ממקור אנלוגי מספר 0

int pot_val; //הגדרת משתנה


 

void setup() {

  // put your setup code here, to run once:

 

Serial.begin(9600);

pinMode(Yellow_Led_Pin,OUTPUT);

pinMode(Green_Led_Pin,OUTPUT);

pinMode(White_Led_Pin,OUTPUT);

}

 

void loop() {

pot_val = analogRead(pot_pin); // הכנסת הערך המספרי של הפטוציומטר למשתנה

Serial.printIn (pot_val); //הדפסת הערך

 

 if (pot_val <= 341){   // לולאה - אם הערך קטן או שווה ל431 הדלק נורה צהובה וכבה נורות ירוקה ולבנה

 digitalWrite(Yellow_Led_Pin,HIGH);

 digitalWrite(Green_Led_Pin,LOW);

 digitalWrite(White_Led_Pin,LOW);

 

 if else (pot_val <= 682) { //  לולאה -אם ההערך קטן או שווה ל682 הדלק נורה ירוקה וכבה נורות צהובה ולבנה

 digitalWrite(Yellow_Led_Pin,LOW);

 digitalWrite(Green_Led_Pin,HIGH);

 digitalWrite(White_Led_Pin,LOW);

 

 else { // לולאה - אם שני התנאים הראשונים לא התקיימו הדלק נורה לבנה וכבה נורות ירוקה וצהובה

 digitalWrite(Yellow_Led_Pin,LOW);

 digitalWrite(Green_Led_Pin,LOW);

 digitalWrite(White_Led_Pin,HIGH);

 

}

delay (500); // חכה חצי שניה

}

 

}

}

 

}

©2022 by My Site. Proudly created with Wix.com

bottom of page