#Include Using Namespace STD

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

Workshop Interface

Selasa, 5 Maret 2019


Lab. H 102
Anggota :
1. Irfan (1110171004)
2. Yogi amtara (1110171011)
3. Rizky Muhammad Panji (1110171023)
4. Alif Ahmad Hakim (1110171024)
Percobaan 0
Pemrograman Rapberry Pi dengan C++
1. Percobaan 0
Program yang digunakan :
#include <iostream>
using namespace std;

int main(int argc, char **argv)


{
cout<<"Hello World" << endl;

return 0;
}
Output yang dihasilkan :

2. Tugas 1
Program yang digunakan :
#include <iostream>
#include <wiringPi.h>
using namespace std;

int ledPin = 29;

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;

int ledPin1 = 29, ledPin2 = 28, ledPin3 = 27, ledPin4 = 25;

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;

int ledPin1 = 29;


int ledPin2 = 28;
int ledPin3 = 27;
int ledPin4 = 26;
int buttonPin = 24;

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 :

Jika PB =1 Running LED, sedangkan PB =0 Blink LED

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy