Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

PRACTICAL WORK 1 ROBOTIC

AHMAD ZAKUAN BIN HASSAN (F1108)

PART A : PW1 CODING ARDUINO

//Name : AHMAD ZAKUAN BIN HASSAN


//Reg.Num : 09DEE21F1108
int RED_LED= 5;
int GRE_LED=4;
int BUZZER = 3;
void setup() {
 // put your setup code here, to run once:
 pinMode(RED_LED,OUTPUT);
 pinMode(GRE_LED,OUTPUT);
 pinMode(BUZZER,OUTPUT);
 }
void loop() {
 // put your main code here, to run repeatedly:
digitalWrite (GRE_LED,HIGH); //LED's ON for 2 sec
delay(2000);
digitalWrite (RED_LED,HIGH); //LED's ON for 3 sec
digitalWrite (GRE_LED,LOW); //LED's OFF for 1 sec
delay(1000);
digitalWrite (BUZZER,HIGH); //BUZZER ON for 1 sec
digitalWrite (RED_LED,LOW); //LED's OFF for 1 sec
delay(1000);
digitalWrite (BUZZER,LOW); //BUZZER OFF for 1 sec
delay(1000);
digitalWrite (BUZZER,HIGH);//BUZZER ON for 1 sec
delay(1000);
digitalWrite (BUZZER,LOW);//BUZZER OFF for 1 sec
delay(1000);
digitalWrite (RED_LED,HIGH); //RED LED ON for 2 sec
digitalWrite (GRE_LED,LOW);
delay(2000);
digitalWrite (RED_LED,LOW); //GREEN LED ON for 2 sec
digitalWrite (GRE_LED,HIGH);
delay(3000);
}
PART B : PW1 CIRCUIT PROTEUS

EXPLAINATION :

at this result, we can see the circuit had led (red,yellow,green),resistor with 220 ohm and 1
sounder already connected to the Arduino uno. After we done checking the coding and compile it,
the led On and off (blinking) every 2 second second, after 2 times blinking the sounder will trigger
with pop” sound on and off every 1 sec.
PART A : ULTRASONIC SENSOR CODING ARDUINO

//Name : AHMAD ZAKUAN BIN HASSAN


//Reg.Num : 09DEE21F1108
const int echoPin = 2; // Echo Pin of Ultrasonic Sensor
const int pingPin = 3; // Trigger Pin of Ultrasonic Sensor
void setup()
{
Serial.begin(9600); // Starting Serial Communication
pinMode(pingPin, OUTPUT); // initialising pin 3 as output
pinMode(echoPin, INPUT); // initialising pin 2 as input
}
void loop()
{
long duration, inches, cm;
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
duration = pulseIn(echoPin, HIGH); // using pulsin function to
determine total time
inches = microsecondsToInches(duration); // calling method
cm = microsecondsToCentimeters(duration); // calling method
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds) // method to covert
microsec to inches
{
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds) // method to covert
microsec to centimeters
{
return microseconds / 29 / 2;
}
PART B : ULTRASONIC SENSOR CIRCUIT PROTEUS

EXPLAINATION :

At this circuit as we can see there a ultrasonic sensor,virtual terminal and also POT H-G already
connected to Arduino uno. Pot H-G need to connect with power and also with ground to complete
the circuit. After we done compile the coding and set the POT H-G to 60% the virtual terminal will
pop the screen and show 263in,673cm if we set the POT H-G to 100% the Virtual Terminal will
increases.
PART A : QUESTION 1 CODING ARDUINO

//Name : AHMAD ZAKUAN BIN HASSAN


//Reg.Num : 09DEE21F1108
int RED_LED= 5;
int GRE_LED=4;
int BUZZER = 3;
void setup() {
 // put your setup code here, to run once:
 pinMode(RED_LED,OUTPUT);
 pinMode(GRE_LED,OUTPUT);
 }
void loop() {
 // put your main code here, to run repeatedly:
digitalWrite (GRE_LED,HIGH); //LED's ON for 1 sec
delay(2000);
digitalWrite (RED_LED,HIGH); //LED's OFF for 1 sec
digitalWrite (GRE_LED,LOW);
delay(3000);
digitalWrite (RED_LED,LOW); //LED's ON for 1 sec
digitalWrite (BUZZER,HIGH);
delay(2000);
digitalWrite (BUZZER,LOW);//BUZZER OFF for 1 sec
delay(5000);
}
PART B : QUESTION 1 CIRCUIT PROTEUS

EXPLAINATION :
on this circuit as we can see there a 2 LED which is Green input 4 and red at input 5, connect with
resistor and ground. There 1 sounder/buzzer input 3 . After done completing the circuit and
compile the Arduino coding, the led green will turn on in 2 seconds. Then, when it change to red
led the green led will turn off. After that, the sounder will pop the sound and led red led will turn
off.
2. Base on the virtual terminal display, explain what will happen if the potentiometer in Figure14

was change to :

a). 25%

- THE DISTANCE DISPLAYED WILL CHANGE WHEN THE POTENTIAL OF THE METER IS CHANGED TO
25% AND THE DISTANCE IS INCREASED TO 111INCH/285CM
b). 50%

- WHEN CHANGING 25% TO 50% THE ULTRA SENSOR CAN DISPLAY A DISTANCE THAT IS FURTHER
COMPARED TO 25%, WHICH IS 219INCH/560CM BECAUSE THE ULTRA SENSOR WORKS TO MEASURE
DISTANCE
c). 75%

- POTENTIAL PERCENTAGE OF THE METER IS RAISED, THE FARTER THE DISTANCE CAN BE MEASURED
BY THE ULTRASENSOR. FOR 75% OF THE ULTRASENSOR CAN MEASURE AT A DISTANCE OF 329
INCH/841CM
DISCUSSION :

In this lab, we’ve been doing 3 circuits which is 2 circuit that we have to followed on the report
and the other one is question. First circuit we using Arduino UNO component, LED, resistor and
sounder. After that we connect the LED to Arduino UNO component. 1 led to 1 pin, red led to
input 7, Yellow led to input 8, Green led to input 9 and the buzzer will go to input 10. After done
the coding we have to compile the coding, to make sure that the coding no error. If there no error
then we can start copy the HEX then paste to Proteus. To do that you have to double click the
Arduino Uno component at proteus then paste it on program file area. Then you will see the
result. On second circuits, we have to do the ultrasonic sensor circuit. The components will be
using is ultrasonic sensor, virtual terminal and also POT-HG. After that when we already choose
the components at proteus we can start the circuits. POT-H-G need to connect with power and
ground. Then, when we done the circuit. We have to do the coding, the coding already given so by
copy the code and compile it at Arduino software. Then copy the HEX paste it to proteus. Last
circuits is tricky one which is the question one. So we supposed to do delay, there a 2 LED which is
Green input 4 and red at input 5, connect with resistor and ground. There 1 sounder/buzzer input
3 . After done completing the circuit and compile the Arduino coding, the led green will turn on in
2 seconds. Then, when it changed to red led the green led will turn off. After that, the sounder will
pop the sound and led red led will turn off.

CONCLUSION :

You might also like