0% found this document useful (0 votes)
16 views1 page

Coding - 1

Uploaded by

Arlene General
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Coding - 1

Uploaded by

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

KYSHA MAUREEN YZOBELLE GENERAL - 10 RESPONSIBLE

While Loop: Potentiometer:


Servo Motor/Led:
int x=5; y=10; void setup(){
#include <Servo.h> void setup() { pinMode (13, OUTPUT);
int servoPin = 9; Serial.begin(9600); pinMode (12, OUTPUT);
while (x<y){ pinMode (11, OUTPUT);
int led1Pin = 2;
Serial.println(“BRSHS”);
int led2Pin = 3;
} void loop(){
int led3Pin = 4; Serial.println("End of loop"); serial.println (analogRead (A0) > 200);
} if (analogRead (A0) > 200) {
Servo myservo; digitalWrite (11, HIGH);
digitalWrite (12, HIGH);
Ultrasonic Sensor: digitalWrite (13, HIGH);
void setup() {
}
Serial.begin(9600); trigPin 12;
echoPin 11; else
myservo.attach(9
{digitalWrite (11, LOW);
myservo.write(0); void setup() {
Serial.begin(9600); digitalWrite (12, LOW);
pinMode(trigPin, OUTPUT); digitalWrite (13, LOW);
pinMode(led1Pin, OUTPUT); pinMode(echoPin, INPUT); }
}
pinMode(led2Pin, OUTPUT); void loop() { }
long duration;
pinMode(led3Pin, OUTPUT); int distance;
}
digitalWrite(trigPin, LOW); LCD:
delay(2);
digitalWrite(trigPin, HIGH); #include <LiquidCrystal.rs>
void loop() { delay(10); int = rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
int angle = myservo.read(); digitalWrite(trigPin, LOW); LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

if (angle >= 0 && angle < 60) { duration = pulseIn(echoPin, HIGH); void setup() {
distance = duration / 58; lcd.begin(16, 2);
digitalWrite(led1Pin, HIGH); Serial.print("Distance: "); // Print "Distance: " lcd.print("Hello, World!");
digitalWrite(led2Pin, LOW); Serial.print(distance); // Print the distance value }
Serial.println(" cm"); // Print " cm" to the serial monitor
digitalWrite(led3Pin, LOW); delay(100); void loop() {
} lcd.setCursor(0, 1);
lcd.print(hour());
} else if (angle >= 60 && angle < 120) { lcd.print(":");
lcd.print(minute());
digitalWrite(led1Pin, HIGH); delay(1000); // Wait for one second
digitalWrite(led2Pin, HIGH); }

digitalWrite(led3Pin, LOW);

} else if (angle >= 120 && angle <= 180) {


digitalWrite(led1Pin, HIGH);
digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, HIGH);
}
Serial.print("Angle: ");
Serial.println(angle);
delay(100);
}

You might also like