Arduino RaspberryPi Lab Manual
Arduino RaspberryPi Lab Manual
Objective:
To understand the Arduino development platform, upload a basic program to blink an LED.
Components Required:
- USB cable
- LED
- 220-ohm resistor
Procedure:
1. Connect the LED anode to pin 13 through a resistor and cathode to GND.
Sample Code:
void setup() {
pinMode(13, OUTPUT);
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
Expected Output:
8. Communicate Between Arduino and Raspberry Pi Using Any Wireless Medium (Bluetooth)
Objective:
Components Required:
- Arduino Uno
- Raspberry Pi
- Jumper wires
Circuit Connections:
- VCC -> 5V
Arduino Code:
void setup() {
Serial.begin(9600);
void loop() {
delay(1000);
import serial
while True:
data = bluetooth.readline()
Arduino / Raspberry Pi Lab Manual
print("Received:", data.decode())
Expected Output:
Objective:
Components Required:
- Raspberry Pi
- Jumper wires
Connections:
Python Code:
while True:
t = strftime("%H%M", localtime())
display.numbers(int(t[:2]), int(t[2:]))
sleep(1)
Arduino / Raspberry Pi Lab Manual
Expected Output:
Objective:
Components Required:
- Raspberry Pi
- MCP3008 ADC
- Jumper wires
Connections:
Python Code:
import spidev
import time
spi = spidev.SpiDev()
spi.open(0,0)
spi.max_speed_hz = 1350000
def read_channel(channel):
return data
x = []
y = []
for i in range(100):
x.append(i)
y.append(read_channel(0))
time.sleep(0.05)
plt.plot(x, y)
plt.title("Oscilloscope Output")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.show()
Expected Output:
Objective:
Components Required:
- LED
Steps:
Python Code:
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
app = Flask(__name__)
@app.route("/whatsapp", methods=['POST'])
def whatsapp():
if 'on' in msg:
GPIO.output(18, GPIO.HIGH)
GPIO.output(18, GPIO.LOW)
return 'OK'
app.run(host='0.0.0.0', port=5000)
Expected Output:
Objective:
Components Required:
Steps:
hostapd.conf Example:
interface=wlan0
driver=nl80211
ssid=PiAccessPoint
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=raspberry123
wpa_key_mgmt=WPA-PSK
Start Services:
Expected Output:
Other devices can see and connect to Raspberry Pi's Wi-Fi network.