Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Republic of the Philippines

CAVITE STATE UNIVERSITY


Don Severino delas Alas Campus
Indang, Cavite

COLLEGE OF ENGINEERING AND INFORMATION TECHNOLOGY


Department of Agricultural and Food Engineering

ABEN23 – Computer Applications in AB Engineering

Name: Pearl Angelie C. Umba Student Number: 201916187


Course, Year and Section: BSABE 4-2 Date: March 30, 2023

Laboratory Activity 1

Instruction. Create a circuit and/or a sketch. Use variables in writing your code. Submit your
code/ program in pdf. For the circuit, submit a video file showing the code in your computer and
the working circuit in google classroom. The pdf and the video file should be submitted
separately.
Circuit and Sketch 2
int ledRed = 8;
int ledYellow = 9;
int ledGreen = 10;

void setup()
{
pinMode(ledRed, OUTPUT);
pinMode(ledYellow, OUTPUT);
pinMode(ledGreen, OUTPUT);
}
void loop()
{
for (int x = 0; x < 5; x = x + 1){
digitalWrite(ledRed, HIGH);
delay(250);
digitalWrite(ledRed, LOW);
delay(250);
}
for (int x = 0; x < 10; x = x + 1){
digitalWrite(ledYellow, HIGH);
delay(250);
digitalWrite(ledYellow, LOW);
delay(250);
}
for (int x = 0; x < 15; x = x + 1){
digitalWrite(ledGreen, HIGH);
delay(250);
digitalWrite(ledGreen, LOW);
delay(250);
}
}
Circuit and Sketch 3

int ledRed = 9; } else if (voltage > 2.0 && voltage


int ledYellow = 10; <= 4.0) {
int ledGreen = 11; digitalWrite(ledGreen, HIGH);
int potpin = A0; digitalWrite(ledRed, LOW);
int potVal; digitalWrite(ledYellow, LOW);
int dt = 1000; Serial.println (potVal);
float voltage;
} else if (voltage > 4.0 && voltage
void setup() < 5.0) {
{ digitalWrite(ledRed, HIGH);
pinMode(ledRed, OUTPUT); digitalWrite(ledYellow, LOW);
pinMode(ledYellow, OUTPUT); digitalWrite(ledGreen, LOW);
pinMode(ledGreen, OUTPUT); Serial.println (potVal);
pinMode(potpin, INPUT);
Serial.begin (9600); } else if (voltage == 5.0) {
} digitalWrite(ledRed, LOW);
digitalWrite(ledYellow, LOW);
void loop() digitalWrite(ledGreen, LOW);
{ Serial.println (potVal);
voltage = (5./1023.)*potVal;
potVal = analogRead (potpin); } else if (voltage == 0) {
Serial.println (voltage); digitalWrite(ledRed, HIGH);
delay (dt); digitalWrite(ledYellow, HIGH);
digitalWrite(ledGreen, HIGH);
if (voltage > 0 && voltage <= 2.0) { Serial.println (potVal);
digitalWrite(ledYellow, HIGH);
digitalWrite(ledRed, LOW); }
digitalWrite(ledGreen, LOW); }
Serial.println (potVal);

You might also like