"Programmaliq injiniringi" Orinbaeva Nabira 1-Laboratoriyaliq jumisi Kerekli úskeneler



Download 74,09 Kb.
Sana31.12.2021
Hajmi74,09 Kb.
#236561
Bog'liq
1 laboratoriya jumisi robot


304-17 “Programmaliq injiniringi” Orinbaeva Nabira

1-Laboratoriyaliq jumisi

Kerekli úskeneler: Arduino UNO R3,aq svetodiot, jasil svetodiot,pereklyuchatel,resistor 220 Ω.

Bul mısal millis () benen waqtın gúzetip baradı, sol sebepli Arduino


belgilengen waqıt aralıǵinda basqa zatlardı islewi múmkin (sensorlardı oqıw hám
t.b.)

int message = 0;

unsigned long TASK_TIME = 10000;

unsigned long BREAK_TIME = 5000;

unsigned long taskDelayStart = 0;

unsigned long breakDelayStart = 0;

bool taskDelayRunning = false;

bool breakDelayRunning = false;

bool taskLightOn = false;
#define taskLampPin 13

#define breakLampPin 12

#define triggerPin 4
void setup() {

pinMode(triggerPin, INPUT_PULLUP); //set up switch pin with internal pullup resistor

pinMode(taskLampPin, OUTPUT);

digitalWrite(taskLampPin, LOW);

pinMode(breakLampPin, OUTPUT);

digitalWrite(breakLampPin, LOW);


// start the serial connection

Serial.begin(9600);

}
void loop() {

message = digitalRead(triggerPin);

if (message == 0){ //if a task is in progress

if (!taskLightOn && !taskDelayRunning & !breakDelayRunning){ // if the lamp is off and neither timer has started yet

taskDelayStart = millis(); //start delay

taskDelayRunning = true; //start the task timer


digitalWrite(taskLampPin, HIGH); //turns on the light

taskLightOn = true;

Serial.println("New task: begin work, and continue...");

}

if (taskLightOn && taskDelayRunning && ((millis() - taskDelayStart) >= TASK_TIME)) { // this code executes when task time is up



taskDelayStart += TASK_TIME; // this prevents drift in the delays

taskDelayRunning = false;

Serial.println("time has elapsed, you've been working hard, take a break");

digitalWrite(breakLampPin, HIGH); //turns on the light

digitalWrite(taskLampPin, LOW); //turns off the light

taskLightOn = false;


breakDelayStart = millis(); //start delay

breakDelayRunning = true;

}

if (!taskLightOn && breakDelayRunning && ((millis() - breakDelayStart) >= BREAK_TIME)) { // this code executes when break time is up



breakDelayStart += BREAK_TIME; // this prevents drift in the delays

breakDelayRunning = false;

Serial.println("break time is over, back to work");

taskDelayRunning = true;

taskDelayStart = millis(); //start delay

digitalWrite(breakLampPin, LOW); //turns on the light

digitalWrite(taskLampPin, HIGH); //turns on the light

taskLightOn = true;

}

}

if (message == 1){ //if task is completed, turn it off



breakDelayRunning = false;

taskDelayRunning = false;

if (taskLightOn){

Serial.println("task complete");

digitalWrite(taskLampPin, LOW); //turns off the light

digitalWrite(breakLampPin, LOW);

taskLightOn = false;

} Serial.println(" waiting for task");



}}
Download 74,09 Kb.

Do'stlaringiz bilan baham:




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish