|
4. Guruh talabasi Karimov Muslimbek
|
tarix | 13.10.2022 | ölçüsü | 208,19 Kb. | | #118269 |
| Amaliy ish 2
Amaliy ish
24.1 Guruh talabasi Karimov Muslimbek
Ishdan maqsad:Arduino platformasida masofa datchigi yordamida 1dona led chirogini PWM pin lari yordamida yonish darajasi belgilansin
Kod qismi
const int TRIG = 4;
const int ECHO = 2;
int masofa;
int led = 5;
void setup(){
Serial.begin(9600);
pinMode(TRIG,OUTPUT);
pinMode(ECHO,INPUT);
pinMode(led, OUTPUT);
}
void loop(){
digitalWrite(TRIG,LOW);
delayMicroseconds(5);
digitalWrite(TRIG,HIGH);
delayMicroseconds(10);
digitalWrite(TRIG,LOW);
masofa = pulseIn(ECHO,HIGH);
masofa = masofa/58;
Serial.print ("Masofa = ");
Serial.print (masofa);
Serial.print (" cm");
Serial.write (10);
delay (200);
analogWrite(led, masofa);
}
Amaliy ishda bajarilgan ish
Xulosa
5-aMALIYDA arduino platformasida masofa datchigida led chirogini pwm pinlari orqali yonish darajasini amalga oshirdik
Dostları ilə paylaş: |
|
|