0% found this document useful (0 votes)
1 views5 pages

Rasberry Programs Solutions

The document outlines various solutions for interfacing microcontrollers (Raspberry Pi, Arduino) with sensors and actuators, including block diagrams and programming examples in Python and C++. It includes code for blinking an LED, turning a buzzer on and off, toggling two LEDs, and observations on input and output behavior. The results confirm successful GPIO control and sensor interfacing, demonstrating basic actuator control and real-time data processing capabilities.

Uploaded by

dumanesakshi9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views5 pages

Rasberry Programs Solutions

The document outlines various solutions for interfacing microcontrollers (Raspberry Pi, Arduino) with sensors and actuators, including block diagrams and programming examples in Python and C++. It includes code for blinking an LED, turning a buzzer on and off, toggling two LEDs, and observations on input and output behavior. The results confirm successful GPIO control and sensor interfacing, demonstrating basic actuator control and real-time data processing capabilities.

Uploaded by

dumanesakshi9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Slip 1- Que 2 Solution :-

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

Ans b) Python code:-

import RPi.GPIO as GPIO


import time
LED_PIN = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
while True:
GPIO.output(LED_PIN, GPIO.HIGH)
time.sleep(1)
GPIO.output(LED_PIN, GPIO.LOW)
time.sleep(1)

---- OR ---------------------------------------
Ans b) C++ Code :-

int LED_PIN = 13;


void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN, LOW);
delay(1000);
}

Ans c) Observations on Input and Output

 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.

d. Result and Conclusion


The LED successfully blinks, proving that the GPIO pins are correctly programmed.

 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

Ans b) Python Code:-

import RPi.GPIO as GPIO

import time

BUZZER_PIN = 18 # GPIO pin for buzzer

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 :-

#define BUZZER_PIN 9 // Define buzzer pin

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
}

Ans c) Observations on Input and Output

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).

d. Result and Conclusion

 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.

Slip 3- 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

Ans b) Python Code:-

import RPi.GPIO as GPIO


import time

# Define LED pin


LED_PIN = 18

# 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------------------------------------------

Ans c. Observations on Input and Output

 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.

d. Result and Conclusion

 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

Ans b) python code:-

import RPi.GPIO as GPIO


import time
LED1 = 18 # GPIO pin for LED 1
LED2 = 23 # GPIO pin for LED 2
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED1, GPIO.OUT)
GPIO.setup(LED2, GPIO.OUT)
try:
while True:
GPIO.output(LED1, GPIO.HIGH)
GPIO.output(LED2, GPIO.LOW)
time.sleep(1)
GPIO.output(LED1, GPIO.LOW)
GPIO.output(LED2, GPIO.HIGH)
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
--------------------------------------------------OR------------------------------------------
Ans b) C++ code:-

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

Ans b) Python Code :-

import RPi.GPIO as GPIO


import time

LED_PIN = 18 # GPIO pin where LED is


connected

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 :-

int LED_PIN = 13; // LED connected to digital pin 13

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
}

Ans c) c. Observations on Input and Output

 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.

d. Result and Conclusion

 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.

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