كورس التحكم فى الالات الدقيقة - شركة انبى
كورس قوى جدا فى مجال التحكم فى العمليات الصناعية من شركة انبى كامل
اتفضلوا لينك التحميل
لينك ثابت - دائم
int trigger_pin = 2; int echo_pin = 3; int buzzer_pin = 10; int time; int distance; void setup ( ) { Serial.begin (9600); pinMode (trigger_pin, OUTPUT); pinMode (echo_pin, INPUT); pinMode (buzzer_pin, OUTPUT); } void loop ( ) { digitalWrite (trigger_pin, HIGH); delayMicroseconds (10); digitalWrite (trigger_pin, LOW); time = pulseIn (echo_pin, HIGH); distance = (time * 0.034) / 2; if (distance <= 10) { Serial.println (" Door Open "); Serial.print (" Distance= "); Serial.println (distance); digitalWrite (buzzer_pin, HIGH); delay (500); } else { Serial.println (" Door closed "); Serial.print (" Distance= "); Serial.println (distance); digitalWrite (buzzer_pin, LOW); delay (500); } }
int trigger_pin = 2; int echo_pin = 3; int buzzer_pin = 10; int time; int distance;
pinMode (trigger_pin, OUTPUT); pinMode (echo_pin, INPUT);
digitalWrite (trigger_pin, HIGH); delayMicroseconds (10); digitalWrite (trigger_pin, LOW); time = pulseIn (echo_pin, HIGH); distance = (time * 0.034) / 2;
if (distance <= 10) { Serial.println (" Door Open "); Serial.print (" Distance= "); Serial.println (distance); digitalWrite (buzzer_pin, HIGH); delay (500); }
#include Servo servo1; Servo servo2; int x_key = A1; int y_key = A0; int x_pos; int y_pos; int servo1_pin = 8; int servo2_pin = 9; int initial_position = 90; int initial_position1 = 90; void setup ( ) { Serial.begin (9600) ; servo1.attach (servo1_pin ) ; servo2.attach (servo2_pin ) ; servo1.write (initial_position); servo2.write (initial_position1); pinMode (x_key, INPUT) ; pinMode (y_key, INPUT) ; } void loop ( ) { x_pos = analogRead (x_key) ; y_pos = analogRead (y_key) ; if (x_pos < 300){ if (initial_position < 10) { } else{ initial_position = initial_position - 20; servo1.write ( initial_position ) ; delay (100) ; } } if (x_pos > 700){ if (initial_position > 180) { } else{ initial_position = initial_position + 20; servo1.write ( initial_position ) ; delay (100) ; } } if (y_pos < 300){ if (initial_position1 < 10) { } else{ initial_position1 = initial_position1 - 20; servo2.write ( initial_position1 ) ; delay (100) ; } } if (y_pos > 700){ if (initial_position1 > 180) { } else{ initial_position1 = initial_position1 + 20; servo2.write ( initial_position1 ) ; delay (100) ; } } }
#include Servo servo1; Servo servo2;
int x_key = A1; int y_key = A0; int x_pos; int y_pos; int servo1_pin = 8; int servo2_pin = 9; int initial_position = 90; int initial_position1 = 90;
servo1.attach (servo1_pin ) ; servo2.attach (servo2_pin ) ; servo1.write (initial_position); servo2.write (initial_position1); pinMode (x_key, INPUT) ; pinMode (y_key, INPUT) ;
x_pos = analogRead (x_key) ; y_pos = analogRead (y_key) ; if (x_pos < 300){ if (initial_position < 10) { } else{ initial_position = initial_position - 20; servo1.write ( initial_position ) ; delay (100) ; } }
if (x_pos > 700){ if (initial_position > 180) { } else{ initial_position = initial_position + 20; servo1.write ( initial_position ) ; delay (100) ; } }
#include <Servo.h> //defining Servos Servo servohori; int servoh = 0; int servohLimitHigh = 160; int servohLimitLow = 20; Servo servoverti; int servov = 0; int servovLimitHigh = 160; int servovLimitLow = 20; //Assigning LDRs int ldrtopl = 2; //top left LDR green int ldrtopr = 1; //top right LDR yellow int ldrbotl = 3; // bottom left LDR blue int ldrbotr = 0; // bottom right LDR orange void setup () { servohori.attach(10); servohori.write(0); servoverti.attach(9); servoverti.write(0); delay(500); } void loop() { servoh = servohori.read(); servov = servoverti.read(); //capturing analog values of each LDR int topl = analogRead(ldrtopl); int topr = analogRead(ldrtopr); int botl = analogRead(ldrbotl); int botr = analogRead(ldrbotr); // calculating average int avgtop = (topl + topr) / 2; //average of top LDRs int avgbot = (botl + botr) / 2; //average of bottom LDRs int avgleft = (topl + botl) / 2; //average of left LDRs int avgright = (topr + botr) / 2; //average of right LDRs if (avgtop < avgbot) { servoverti.write(servov +1); if (servov > servovLimitHigh) { servov = servovLimitHigh; } delay(10); } else if (avgbot < avgtop) { servoverti.write(servov -1); if (servov < servovLimitLow) { servov = servovLimitLow; } delay(10); } else { servoverti.write(servov); } if (avgleft > avgright) { servohori.write(servoh +1); if (servoh > servohLimitHigh) { servoh = servohLimitHigh; } delay(10); } else if (avgright > avgleft) { servohori.write(servoh -1); if (servoh < servohLimitLow) { servoh = servohLimitLow; } delay(10); } else { servohori.write(servoh); } delay(50); }