Rasberry Programs Solutions
Rasberry Programs Solutions
Draw block diagram /pin diagram of Raspberry-Pi/ Beagle board /Arduino Uno board interfacing with IR
Sensor/Temperature Sensor/Camera. (Internal Examiner assign any one option for board and interface
device and respective interface programming option) b. WAP in python/C++ language to blink LED. c. Write
down the observations on Input and Output d. Write down the Result and Conclusion
Ans a) Block Diagram
---- OR ---------------------------------------
Ans b) C++ Code :-
Input: The Raspberry Pi reads temperature data from the sensor and processes it.
Output: The LED blinks with a delay of 1 second, verifying correct GPIO configuration.
The interfacing of the Temperature Sensor with the Raspberry Pi enables real-time data collection
and processing.
Slip 2- Que 2 Solution :-
a. Draw block diagram /pin diagram of Raspberry-Pi/ Beagle board /Arduino Uno board interfacing with IR
Sensor/Temperature Sensor/Camera. (Internal Examiner assign any one option for board and interface device and
respective interface programming option) b. WAP in python/C++ language to turn ON/OFF buzzer. c. Write down the
observations on Input and Output d. Write down the Result and Conclusion
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(BUZZER_PIN, GPIO.OUT)
try:
print("Buzzer ON")
GPIO.output(BUZZER_PIN, GPIO.HIGH) #
Turn ON
time.sleep(2) # Keep ON for 2 seconds
print("Buzzer OFF")
GPIO.output(BUZZER_PIN, GPIO.LOW) # Turn OFF
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
------------------------------------------ OR -----------------------------------------
Ans b) C++ code :-
void setup() {
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
digitalWrite(BUZZER_PIN, HIGH); // Turn buzzer ON
delay(2000); // Keep ON for 2 seconds
digitalWrite(BUZZER_PIN, LOW); // Turn buzzer OFF
delay(2000); // Wait 2 seconds before repeating
}
1. When the program runs, the buzzer turns ON for 2 seconds and then turns OFF.
2. The buzzer remains silent until the loop repeats (in case of Arduino).
3. If a sensor is used, the buzzer can be activated based on input signals (e.g., IR sensor detection or
temperature threshold).
The buzzer was successfully turned ON and OFF using Python (Raspberry Pi) and C++ (Arduino).
The interfacing between the microcontroller/microprocessor and the sensor was verified.
This experiment demonstrates basic actuator control and can be expanded for alarm systems or
automation applications.
a. Draw block diagram /pin diagram of Raspberry-Pi/ Beagle board /Arduino Uno board interfacing with IR
Sensor/Temperature Sensor/Camera. (Internal Examiner assign any one option for board and interface
device and respective interface programming option) b. WAP in python/C++ language to blink LED. c. Write
down the observations on Input and Output d. Write down the Result and Conclusion
# Set up GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
try:
while True:
GPIO.output(LED_PIN, GPIO.HIGH) #
Turn LED ON
time.sleep(1) # Wait 1 second
GPIO.output(LED_PIN, GPIO.LOW) # Turn LED OFF
time.sleep(1) # Wait 1 second
except KeyboardInterrupt:
GPIO.cleanup() # Cleanup GPIO on exit
---------------------------------OR------------------------------------------
Input: The program sends HIGH (1) and LOW (0) signals to the LED at 1-second intervals.
Output: The LED blinks continuously, turning ON and OFF every second.
Result: The LED successfully blinks at 1-second intervals as per the programmed logic.
Conclusion: The experiment demonstrates the ability to control external hardware using Python/C++
and GPIO pins on microcontrollers or single-board computers.
Slip 4- Que 2 Solution :-
a. Draw block diagram /pin diagram of Raspberry-Pi/ Beagle board /Arduino Uno board interfacing with IR
Sensor/Temperature Sensor/Camera. (Internal Examiner assign any one option for board and interface
device and respective interface programming option) b. WAP in python/C++ language to toggle two LED’s. c.
Write down the observations on Input and Output d. Write down the Result and Conclusion
int LED1 = 9;
int LED2 = 10;
void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
}
void loop() {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, LOW);
delay(1000);
digitalWrite(LED1, LOW);
digitalWrite(LED2, HIGH);
delay(1000);
}
Ans c. Observations on Input and Output
Input: No physical button is required; the microcontroller continuously toggles the LEDs every
second.
Output: The LEDs alternately turn ON and OFF at 1-second intervals.
d. Result and Conclusion
Result: Successfully interfaced and programmed the Raspberry Pi / Arduino to toggle two LEDs.
Conclusion:
The experiment demonstrates how to control GPIO pins using Python (for Raspberry Pi) or C++ (for
Arduino).
Basic LED toggling is useful for learning about microcontroller I/O control and timing functions.
Slip 5- Que 2 Solution :-
a. Draw block diagram /pin diagram of Raspberry-Pi/ Beagle board /Arduino Uno board interfacing with IR
Sensor/Temperature Sensor/Camera. (Internal Examiner assign any one option for board and interface
device and respective interface programming option) b. WAP in python/C++ language to blink LED. c. Write
down the observations on Input and Output d. Write down the Result and Conclusion
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
try:
while True:
GPIO.output(LED_PIN, GPIO.HIGH) #
Turn LED ON
time.sleep(1) # Wait for 1 second
GPIO.output(LED_PIN, GPIO.LOW) # Turn LED OFF
time.sleep(1) # Wait for 1 second
except KeyboardInterrupt:
GPIO.cleanup() # Clean up resources on exit
-------------------------------------------------------OR-----------------------------------------------------
Ans b) C++ Code :-
void setup() {
pinMode(LED_PIN, OUTPUT); // Set pin as output
}
void loop() {
digitalWrite(LED_PIN, HIGH); // Turn LED ON
delay(1000); // Wait for 1 second
digitalWrite(LED_PIN, LOW); // Turn LED OFF
delay(1000); // Wait for 1 second
}
Input: The IR sensor detects an object and sends a HIGH or LOW signal to the microcontroller.
Output: The LED blinks at a 1-second interval as per the program.
Behavior: The LED turns ON when the microcontroller sends a HIGH signal and turns OFF when a
LOW signal is sent.
The interfacing between the microcontroller (Arduino/Raspberry Pi) and the IR sensor was
successfully established.
The LED blinked successfully, indicating correct GPIO control using Python (Raspberry Pi) and C+
+ (Arduino).
The experiment demonstrates the ability of microcontrollers to control external devices based on
sensor inputs.