1. Rele. Releni tranzistor orqali boshqarish void setup


Download 34.86 Kb.
Sana18.06.2023
Hajmi34.86 Kb.
#1568584
Bog'liq
3-topshiriq

1.Rele. Releni tranzistor orqali boshqarish.




void setup()

{
pinMode(7, OUTPUT);
}
void loop()
{
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
}
2. Fotoqarshilik. Yorug‘lik diodlarini yoqish yoki o‘chirish orqali yorug‘lik darajasiga ishlov berish.

https://www.tinkercad.com/things/8pjNO3HjnYd



//Otro:
// Photocell simple testing sketch.
/*Connect one end of the photocell to 5V, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground
Connect LED from pin 11 through a resistor to ground
For more information see http://learn.adafruit.com/photocells */
int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the sensor divider
int LEDpin = 9; // connect Red LED to pin 9 (PWM pin)
int LEDbrightness;
//
void setup(){
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
}
void loop(void) {
photocellReading = analogRead(photocellPin);
// LED gets brighter the darker it is at the sensor
// that means we have to -invert- the reading from 0-1023 back to 1023-0
photocellReading = 1023 - photocellReading;
//now we have to map 0-1023 to 0-255 since thats the range analogWrite uses
LEDbrightness = map(photocellReading, 0, 1023, 0, 255);
analogWrite(LEDpin, LEDbrightness);
Serial.print("Analog reading = ");
Serial.print(photocellReading); // the raw analog reading
// We'll have a few threshholds, qualitatively determined
if (photocellReading < 10) {
Serial.println(" - Dark");
} else if (photocellReading < 200) {
Serial.println(" - Dim");
} else if (photocellReading < 500) {
Serial.println(" - Light");
} else if (photocellReading < 800) {
Serial.println(" - Bright");
} else {
Serial.println(" - Very bright");
}
delay(300);
}
/* Use a photoresistor (or photocell) to turn on an LED in the dark
//Constants
const int pResistor = A0; // Photoresistor at Arduino analog pin A0
const int ledPin=9; // Led pin at Arduino pin 9
//Variables

int value; // Store value from photoresistor (0-1023)
void setup(){

Serial.begin(9600);
pinMode(ledPin, OUTPUT); // Set lepPin - 9 pin as an output
pinMode(pResistor, INPUT);// Set pResistor - A0 pin as an input (optional)
}
void loop(){

value = analogRead(pResistor);
Serial.print("valor");
Serial.println(value);
//va de 54 min a 974 max con R=10kohm (con otra R cambian valores picos
if (value > 800){
digitalWrite(ledPin, LOW); //Turn led off
}
else{
digitalWrite(ledPin, HIGH); //Turn led on
}
}
*/


3. LM335 xarorat datchigi (uzuluksiz). Ishlash tamoili, ishlatishga misol..


https://www.tinkercad.com/things/7yRK2SXuRXm
// include the library code for LCD display:

#include
// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


// Defining pin

#define temp A5


#define led 13
void setup()

{
// set up the LCD's number of columns and rows:


lcd.begin(16, 2);
pinMode(led, OUTPUT);
pinMode(temp, INPUT);
Serial.begin(9600);
lcd.clear();
lcd.print("Temperature: ");
}
//Global Variable
float pre_temp = 0;
void loop() {
float temperature = 0;
temperature = (analogRead(temp) * 0.48828125) - 49.95;
if(pre_temp != temperature)
{
lcd.setCursor(0,1);
lcd.print(" ");
}
lcd.setCursor(0,1);
lcd.print(temperature);
lcd.print(" C");
pre_temp = temperature;
}

4. RGB-yorug‘lik diodi. Impuls kengligining modulyatsiyasi.


https://www.tinkercad.com/things/7BVBKcoP82G


int pinred = 10;
int pinblue = 9;
int pingreen = 8;
int potenred;

int potenblue;


int potengreen;
void setup()

{
pinMode(10, OUTPUT);


pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
}
void loop()

{
potenred = map(analogRead(A2), 0, 1023, 0, 255);


potenblue = map(analogRead(A1), 0, 1023, 0, 255);
potengreen = map(analogRead(A0), 0, 1023, 0, 255);
analogWrite(pinred, potenred);
analogWrite(pinblue, potenblue);
analogWrite(pingreen, potengreen);
delay(50);
}
2-Fotoqarshilik. Yorug‘lik diodlarini yoqish yoki o‘chirish orqali yorug‘lik darajasiga ishlov berish.
3. LM335 xarorat datchigi (uzuluksiz). Ishlash tamoili, ishlatishga misol.
Download 34.86 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling