0% found this document useful (0 votes)
59 views6 pages

4 Lab Zarnigor

This document discusses using a potentiometer to control the brightness of a light-emitting diode (LED) using an Arduino board. It describes the necessary hardware, including an Arduino board, potentiometer, breadboard, LED, and wires. It provides the Arduino code to read the potentiometer value and use it to control the brightness of the LED through pulse-width modulation of the LED.

Uploaded by

Ahmad Bobojonov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views6 pages

4 Lab Zarnigor

This document discusses using a potentiometer to control the brightness of a light-emitting diode (LED) using an Arduino board. It describes the necessary hardware, including an Arduino board, potentiometer, breadboard, LED, and wires. It provides the Arduino code to read the potentiometer value and use it to control the brightness of the LED through pulse-width modulation of the LED.

Uploaded by

Ahmad Bobojonov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lobaratoriya mashg‘ulot № 4

Mavzu: Potensiometr. Arduino orqali yorug'lik diodini yorug'lik darajasini


o'zgartirishini namoyish etish.

Ishdan maqsad: Sanoatda o’zgaruvchan qarshiliklardan foydalanishni o’rganish


va ularni ishlatishni amalda bajarib ko’rish.

Kerakli jixozlar:
 VVB dasturi yoki arduino plata qurilmasi.

 Breadboard.

 USB Kabel.

 O’zgaruvchan qarshilik

 Kerakli ehtiyot qismlari.

Jixozlarning vazifalari:

VVB dasturi yoki arduino plata qurilmasi. Istalgan kerakli qurilmalarni


tizimlashtirish imkoniyatiga ega va avtomatik tarzda ishlash
xususiyatlariga ega.

Breadboard. Ehtiyot qismlarini o‘rnatish platasi ya’ni (zapchast) larni o‘rnatish


uchun va qurilmani tizim orqali tekshirib ko‘rishimiz uchun kerak bo‘ladi.

USB Kabel. Bu kabellar Arduino qurilmasini kompyuterga ulash uchun


foydalanamiz.

Kerakli ehtiyot qismlari. Masalan o’zgaruvchan qarshilik (svetodiod),


(qarshiliklar) va x.k.z.
1-rasm. O’zgaruvchan qarshilik
2-rasm (Arduino uno platasiga potensiometr ya’ni o’zgaruvchan
qarshilikning ulanish sxemasi)

Dastur qismi

static final int analogInPin = 0; // Analog input pin that the potentiometer is
attached to

static final int analogOutPin = 9; // Analog output pin that the LED
is attached to

static final int HOME = 2;


int sensorValue = 0; // value read from the pot

int outputValue = 0; // value output to the PWM (analog out)


public void setup() {

/ initialize serial communications at 9600


bps: Serial.begin(9600);

}
public void loop() {
// read the analog in value:

sensorValue = analogRead(analogInPin);

/ map it to the range of the analog out:


outputValue = map(sensorValue, 0, 1023, 0,
255);

/ change the analog out value:


analogWrite(analogOutPin,
outputValue);

/ print the results to the serial


monitor: Serial.write(HOME);
Serial.print("sensor = ");
Serial.println(sensorValue);
Serial.print("output = ");
Serial.println(outputValue);

delay(100);

}
}
int led1 = 3;

int led2 = 6;

int led3 = 9;

int led4 = 11;

int poten = A0;

int delayperiod = 0;

void setup()

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led3, OUTPUT);

pinMode(led4, OUTPUT);
pinMode(poten, INPUT);

void loop()

int invalue = analogRead(poten);

delayperiod = map(invalue, 0,1023,0,1000);

digitalWrite(led1, HIGH);

delay(delayperiod);

digitalWrite(led2, HIGH);

delay(delayperiod);

digitalWrite(led3, HIGH);

delay(delayperiod);

digitalWrite(led4, HIGH);

delay(delayperiod);

digitalWrite(led1, LOW);

delay(delayperiod);

digitalWrite(led2, LOW);

delay(delayperiod);

digitalWrite(led3, LOW);

delay(delayperiod);

digitalWrite(led4, LOW);

delay(delayperiod);

You might also like