#Include Using Namespace STD
#Include Using Namespace STD
#Include Using Namespace STD
return 0;
}
Output yang dihasilkan :
2. Tugas 1
Program yang digunakan :
#include <iostream>
#include <wiringPi.h>
using namespace std;
void setup(){
pinMode (ledPin,OUTPUT);
cout<<"Hello World" << endl;
}
void loop(){
digitalWrite(ledPin,HIGH);
delay(1000);
cout<<"LED ON" << endl;
digitalWrite(ledPin,LOW);
delay(1000);
cout<<"LED OFF" << endl;
int main(void)
{
if(wiringPiSetup()<0){
cout<<"setup wiring pi failed"<<endl;
return 1;
}
setup();
while(1){
loop();
}
return 0;
}
Output yang dihasilkan :
Blink LED
3. Tugas 2
Program yang digunakan :
#include <iostream>
#include <wiringPi.h>
using namespace std;
void setup(){
pinMode (ledPin1,OUTPUT);
pinMode (ledPin2,OUTPUT);
pinMode (ledPin3,OUTPUT);
pinMode (ledPin4,OUTPUT);
cout<<"Hello World" << endl;
}
void loop(){
digitalWrite(ledPin1,HIGH);
delay(500);
cout<<"LED ON" << endl;
digitalWrite(ledPin1,LOW);
delay(500);
cout<<"LED OFF" << endl;
digitalWrite(ledPin2,HIGH);
delay(600);
cout<<"LED ON" << endl;
digitalWrite(ledPin2,LOW);
delay(600);
cout<<"LED OFF" << endl;
digitalWrite(ledPin3,HIGH);
delay(700);
cout<<"LED ON" << endl;
digitalWrite(ledPin3,LOW);
delay(700);
cout<<"LED OFF" << endl;
digitalWrite(ledPin4,HIGH);
delay(800);
cout<<"LED ON" << endl;
digitalWrite(ledPin4,LOW);
delay(800);
cout<<"LED OFF" << endl;
int main(void)
{
if(wiringPiSetup()<0){
cout<<"setup wiring pi failed"<<endl;
return 1;
}
setup();
while(1){
loop();
}
return 0;
}
Output yang dihasilkan :
Running LED
4. Tugas 3
Program yang digunakan :
#include <iostream>
#include <wiringPi.h>
using namespace std;
void setup(){
pinMode (ledPin1,OUTPUT);
pinMode (ledPin2,OUTPUT);
pinMode (ledPin3,OUTPUT);
pinMode (ledPin4,OUTPUT);
pinMode (buttonPin,INPUT);
cout<<"Hello World" << endl;
}
void loop(){
if digitalRead (buttonPin==1)
{ cout << "TOMBOL AKTIF" << endl;
digitalWrite(ledPin1,HIGH);
delay(500);
digitalWrite(ledPin1,LOW);
delay(500);
digitalWrite(ledPin2,HIGH);
delay(600);
digitalWrite(ledPin2,LOW);
delay(600);
digitalWrite(ledPin3,HIGH);
delay(700);
digitalWrite(ledPin3,LOW);
delay(700);
digitalWrite(ledPin4,HIGH);
delay(800);
digitalWrite(ledPin4,LOW);
delay(800);
}
else
{cout <<"TOMBOL TIDAK AKTIF"<< endl;
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,HIGH);
delay(100);
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);
delay(100);}
}
int main(void)
{
if(wiringPiSetup()<0){
cout<<"setup wiring pi failed"<< endl;
return 1;
}
setup();
while(1){
loop();
}
return 0;
}
Output yang dihasilkan :