3-Laboratoriya ishi Mavzu: Tugma,Yorug‘lik diodini yoqish misolida tugmaning bosilishiga ishlov berish
Download 0.79 Mb.
|
3-lab ish
- Bu sahifa navigatsiya:
- BUTTON
3-Laboratoriya ishi Mavzu: Tugma,Yorug‘lik diodini yoqish misolida tugmaning bosilishiga ishlov berish. Ishdan maqsad: Arduinoda dastur yozish va Prateusda knopkalar bilan ishlashni o’rganish. 1-rasm. Arduino muhutini ishga tushgan holati. 2-rasm. Arduino muhutiga dasturni yozgan holat. Dasturimi to’g’ri yozganimizdan so’ng dasturni hex. Filini prateus muhitida yi’g’ilgan sxemaga ko’rsatishimiz kerak. 3-rasm. Arduino muhutida yozilgan dasturimizning hex.fili ushbu filni nusxa olib prateusdagi sxemaga qo’yamiz. 4-rasm.Proteus muhutining ishga tushurish va yangi projectyaratish New Project tugmasini bosamiz. 5-rasm. Yaratgan projectni qayerga saqlagan joyini ko’rsatadi va Finish tugmasini bosib davom etamiz. 6-rasm. Arduino uno ni proteus muhutiga joylashtirilgan holati. 7-rasm. Proteus muhutini ishga tushuramiz va BUTTON knopkasini bosamiz. Button knopkasini bosganimizda LED ni yonishini, buttonni qo’yganimizda LED ni o’chishini ko’rishimiz mumkun. Dastur kodi: int buttonPin = 2; int ledPin1 = 12; int ledPin2 = 11; int ledPin3 = 9; int buttonState = 0; void setup() { pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); pinMode(ledPin3, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { //digitalWrite(ledPin, LOW); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin1, HIGH); } else { // turn LED off: digitalWrite(ledPin1, LOW); } buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { digitalWrite(ledPin2, HIGH); } else { // turn LED off: digitalWrite(ledPin2, LOW); } buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { digitalWrite(ledPin3, HIGH); } else { // turn LED off: digitalWrite(ledPin3, LOW); } } Download 0.79 Mb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling