Professional Documents
Culture Documents
PRACTICAL 1
STEP 1:
Open the Raspberry Pi Shell terminal
STEP 2:
Type in pwd
pi@raspberry:~ $ pwd
STEP 3:
Type in ls
pi@raspberry:~ $ ls
Type in cd Desktop
pi@raspberry:~ $ cd Desktop/
Now type in ls
pi@raspberry:~/Desktop $ ls
And see what is returned is the same as what is the contents of the GUI of the Desktop
STEP 5:
Now type in ls
pi@raspberry:~/Desktop $ ls
And see what is returned is the same as what is the contents of the GUI of the Desktop
STEP 7:
STEP 8:
pi@raspberry:~/Desktop $ rm NewFile.txt
Now type in ls
pi@raspberry:~/Desktop $ ls
STEP 2:
First we need to download the wiringPi Library on the Raspberry Pi
Open Up Shell terminal
Type in git clone git://git.drogon.net/wiringPi
#include <stdio.h>
#include <wiringPi.h>
int main(void)
{
printf(“Raspberry Pi Led Control C++\n”);
wiringPiSetupGpio();
int LED = 17;
pinMode(LED, OUTPUT);
for (int x=0; x<5;x++)
{
digitalWrite(LED,HIGH);
delay(500);
digitalWrite(LED,LOW);
delay(500);
}
return 0;
}
Write the C++ source code below:
Once Written Press Ctrl+S to Save
STEP 5:
Press Build, then press Set Build Commands
Then Press Ok and press F9 to Build, Press F5 to Execute, wait for the LED to blink 5 times
PRACTICAL 4
#include <stdio.h>
#include <wiringPi.h>
int main(void)
{
printf(“Raspberry Pi Button Check C++\n”);
wiringPiSetupGpio();
int isButtonPin = 17;
int ledShine = 18;
pinMode(isButtonPin,INPUT);
pinMode(ledShine,OUTPUT);
int prevButton = HIGH, LED =0;
digitalWrite(ledShine,LOW);
for (;;)
{
if (prevButton == HIGH && digitalRead(isButtonPin) == LOW);
{
prevButton = LOW;
if (LED)
{
LED = 0;
digitalWrite(ledShine,LOW);
}
else
{
LED =1;
digitalWrite(ledShine,HIGH);
}
}
else if (prevButton == LOW && digitalRead(isButtonPin) == HIGH)
{
prevButton=HIGH;
}
}
return 0;
}
STEP 3:
Press F9 to Build
Press F5 to Execute and Observe the Shell Terminal
PRACTICAL 5
#include <stdio.h>
#include <wiringPi.h>
int main(void)
{
printf(“Raspberry Pi Buzzer Check C++\n”);
wiringPiSetupGpio();
int isButtonPin = 17;
int isBuzzerPin = 18;
pinMode(isButtonPin,INPUT);
pinMode(isBuzzerPin,OUTPUT);
int prevButton = HIGH, Buzzers =0;
digitalWrite(isBuzzerPin,HIGH);
for (;;)
{
if (prevButton == HIGH && digitalRead(isButtonPin) == LOW);
{
prevButton = LOW;
if (Buzzers)
{
Buzzers = 0;
digitalWrite(isBuzzerPin,LOW);
}
else
{
Buzzers =1;
digitalWrite(isBuzzerPin,HIGH);
}
}
else if (prevButton == LOW && digitalRead(isButtonPin) == HIGH)
{
prevButton=HIGH;
}
delay(5);
}
return 0;
}
STEP 3:
Press F9 to Build ->Press F5 to Execute and Observe the Shell Terminal
PRACTICAL 6
#include <stdio.h>
#include <wiringPi.h>
int main(void)
{
printf(“Raspberry Pi Sound Check C++\n”);
wiringPiSetupGpio();
int isSoundPin = 18;
int led = 17;
pinMode(isSoundPin,INPUT);
pinMode(led,OUTPUT);
for (int x=0; x<20;x++)
{
if (digitalRead(isSoundPin));
{
printf(“There is NO SOUND!\n”);
digitalWrite(led,LOW);
}
else
{
printf(“There is SOUND!\n”);
digitalWrite(led,HIGH);
}
delay(500);
}
return 0;
}
STEP 3:
Press F9 to Build
Press F5 to Execute
Observe the Shell Terminal
PRACTICAL 7
Objective IR Sensor
Hardwar 1. Raspberry Pi
Requirement 2. Breadboard
3. IR sensor
4. 3 female-to-female Jumper Wire
#include <stdio.h>
#include <wiringPi.h>
int main(void)
{
printf(“Raspberry Pi IR Check C++\n”);
wiringPiSetupGpio();
int isObstaclePin = 18;
pinMode(isObstaclePin,INPUT);
for (int x=0; x<10;x++)
{
if (digitalRead(isObstaclePin));
{
printf(“There is NO OBSTACLE!\n”);
}
else
{
printf(“There is OBSTACLE!\n”);
}
delay(500);
}
return 0;
}
STEP 3:
Press F9 to Build
Press F5 to Execute
Observe the Shell Terminal