Sepk Lab7
Sepk Lab7
ASSIGNMENT
Familiarization with Analogue to
Digital Converter (ADC) using various
07 sensors and Actuators interfacing With
Raspberry Pi Pico and LEDs.
Aim:
Familiarization with Analogue to Digital Converter (ADC) using various sensors and
actuators interfacing with Raspberry Pi Pico and LEDs.
Objectives:
1) Introduction to Analogue to Digital Converter (ADC) Technique, its behaviour and applications.
2) Implementation of ADC on Micro-python with Raspberry Pi - Turn the Knob: Welcome to
Analog World.
3) Implementation of ADC on Micro-python with Raspberry Pi - Turn the Knob: Control an LED
using POT.
4) Implementation of Swinging Servo using Raspberry Pi with control systems that require constant
angle changes.
5) Implementation of Swing the servo from left to right using POT with ADC technique using
Raspberry Pi.
6) Implementation of Thermometer: Calculation of Temperature using thermistor module and
Raspberry Pi.
7) Implementation of a LDR Testing to calculate the Percentage of Light using LDR module and
Raspberry Pi.
8) Implementation of a Light Theremin: Electronic musical instrument using LDR module and
Raspberry Pi.
Summary of Experiment - 7 Goals and OutcomesBy
the end of this experiment, students will have gained a solid understanding of IoT fundamentals,
Raspberry Pi Pico, Python programming, and practical experience in building and controlling
IoT-related hardware to establish communication between the analogue and digital world.
These skills will facilitate as a strong foundation for more complex IoT projects in the future.
Pre-Lab Questionnaire:
1) What is the resolution of the ADC on the Raspberry Pi Pico?
2) How many ADC channels does the Raspberry Pi Pico have?
3) What is the maximum sample rate of the ADC on the Raspberry Pi Pico?
4) How do you configure and use the ADC on the Raspberry Pi Pico in MicroPython?
5) How does the voltage range of the ADC on the Raspberry Pi Pico affect the resolution?
6) What is the voltage range of the ADC on the Raspberry Pi Pico?
7) How is the voltage level measured by the ADC on the Raspberry Pi Pico converted to a
digital value?
8) How does the number of bits in the ADC resolution affect the accuracy of the readings?
9) How can you reduce noise in the readings from the ADC on the Raspberry Pi Pico?
10) What is the input impedance of the ADC on the Raspberry Pi Pico?
Components/Equipment Required:
Sl. Name of the Specification Quantity
No. Component / Equipment
1) Raspberry Pi Pico RP2040 microcontroller chip, 1
125MHz
2) Raspberry Pi Pico cable USB Type A to Micro-B 1
3) Resistors (carbon type) ¼ watt (330 Ω) 1
4) LED 3mm, Red 1
5) Trimmer Pot 10k 1
6) Mini Servo Motor SG 90, Plastic Gear 1
7) Thermister Module KY-013 Analog Temperature Sensor 1
Module
8) LDR Light Sensor 5mm 1
9) Transistor NPN, 2N2222 1
10) Buzzer Active, Small 1
11) Breadboard 840 Tie points 1
12) Jumper Wire --------------------------- As per requirement
Objective 1
Objective 2
Implementation of ADC on Micro-python with Raspberry Pi Pico- Turn the Knob: Welcome to
Analog World.
Circuit/Schematic Diagram:
2.1: write a program that implement an ADC on Micro-python with Raspberry Pi Pico-
Turn the Knob: Welcome to Analogue World.
import machine
import utime
analog_value = machine.ADC(28)
while True:
reading = analog_value.read_u16()
print("ADC: ",reading)
utime.sleep(0.2)
Observation
Figure 2: (Simulation based electronic circuit for implementation of ADC on Micro-python with
Raspberry Pi - Turn the Knob: Welcome to Analog World.)
Figure 3: (Hardware based electronic circuit for implementation of ADC on Micro-python with
Raspberry Pi - Turn the Knob: Welcome to Analog World.)
Objective 3
Implementation of ADC on Micro-python with Raspberry Pi Pico- Turn the Knob: Control an
LED using POT.
Circuit/Schematic Diagram:
(Figure 4: Circuit diagram for implementation of ADC on Micro-python with Raspberry Pi Pico- Turn the Knob:
Control an LED using POT.)
Code
import machine
import utime
potentiometer = machine.ADC(28)
led = machine.PWM(machine.Pin(15))
led.freq(1000)
while True:
value=potentiometer.read_u16()
print(value)
led.duty_u16(value)
utime.sleep_ms(200)
Observation
Figure 5: (Simulation based electronic circuit for implementation of ADC on Micro-python with
Raspberry Pi - Turn the Knob: Control a LED using POT .)
Figure 6: (Hardware based electronic circuit for implementation of ADC on Micro-python with
Raspberry Pi - Turn the Knob: Control a LED using POT .)
Objective 4
4.1. Implementation of Swinging Servo using Raspberry Pi Pico with control systems that
require constant angle changes.
(Figure 7: Circuit diagram for implementation of Swinging Servo using Raspberry Pi with control systems that
require constant angle changes.)
Code
4.1: write a program for the implementation of Swinging Servo using Raspberry Pi Pico
with control systems that require constant angle changes.
servo = PWM(Pin(15))
servo.freq(50)
def interval_mapping(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
def servo_write(pin, angle):
pulse_width=interval_mapping(angle, 0, 180, 0.5,2.5)
duty=int(interval_mapping(pulse_width, 0, 20, 0,65535))
pin.duty_u16(duty)
while True:
for angle in range(180):
servo_write(servo, angle)
sleep_ms(20)
for angle in range(180,-1,-1):
servo_write(servo, angle)
sleep_ms(20)
Observation
Figure 8: (Simulation based Swinging Servo using Raspberry Pi Pico with control systems
that require constant angle changes.)
Figure 9: (Hardware based Swinging Servo using Raspberry Pi Pico with control systems
that require constant angle changes.)
Objective 5
5.1: write a program for the implementation of Swing the servo from left to right using POT
with ADC technique using Raspberry Pi Pico.
(Figure 10: Circuit diagram for implementation of Swing the servo from left to right using POT with ADC
technique using Raspberry Pi.)
Code
5.1: write a program for the implementation of Swing the servo from left to right using POT
with ADC technique using Raspberry Pi Pico.
Observation
Figure 11: (Simulation based Swing the servo from left to right using POT with ADC technique using
Raspberry Pi Pico.)
Figure 12: (Hardware based Swing the servo from left to right using POT with ADC technique using
Raspberry Pi Pico.)
Objective 6
6.1 Implementation of Thermometer: Calculation of Temperature using thermistor module
and Raspberry Pi Pico
Circuit / Schematic Diagram
(Figure 13: Circuit diagram for implementation of Thermometer: Calculation of Temperature using thermistor
module and Raspberry Pi.)
Code
Observation
Figure 15: (Hardware implementation based electronic circuit for implementation of Thermometer:
Calculation of Temperature using thermistor module with Raspberry Pi Pico.)
Objective 7
7.1. Implementation of a LDR Testing to calculate the Percentage of Light using LDR module
on Micro-python with Raspberry Pi Pico.
(Figure 16: Circuit diagram for implementation of a LDR Testing to calculate the Percentage of Light using LDR
module and Raspberry Pi.)
Code
Write a program for implementation of a LDR Testing to calculate the Percentage of Light
using LDR module on Micro-python with Raspberry Pi Pico.
Observation
Figure 17: (Simulation-based electronic circuit for implementation of a LDR Testing to calculate the
Percentage of Light using LDR module and Raspberry Pi Pico.)
Figure 18: (Hardware implementation based electronic circuit for implementation of a LDR Testing to
calculate the Percentage of Light using LDR module and Raspberry Pi Pico.)
Objective 8
8.1. Implementation of a Light Theremin: Electronic musical instrument using LDR module
on Micro-python and Raspberry Pi Pico.
Circuit / Schematic Diagram
(Figure 19: Circuit diagram for implementation of a Light Theremin: Electronic musical instrument using LDR
module and Raspberry Pi.)
Code
Observation
Figure 20: (Hardware implementation based electronic circuit for implementation of a Light
Theremin: Electronic musical instrument using LDR module and Raspberry Pi Pico.)