This is my make-through for the week's assignment. Grab a cup of coffee!
This week was an introduction to raspberry pi and how does it works from a hardware and software perspective and at the of the week we've passed through lessons like getting started with raspberry pi and how to read data from digital sensors also we were asked to do an assignment which controls an input and output.
this is not my first time with Rpi but actually i haven't used its GPIO Pins because i was using it as mini PC
A big difference between arduino or AVR and the RPI particularly the when comparing the Atmel AVR vs something like like Pi is the amount of resources available for code and data.
An AVR typically has 32k up to 128k of flash for code and 2k up to 16k for RAM.
(not MB or GB but Kbytes)
The AVR does not allow running code in RAM and does not support direct data access to flash.
after checking the inventory list i decided to choose the IR sensor module as an input and LED as an output
The output of the IR sensor module is a digital signal and it gets powered from the GPIO Power pins
For the wiring i have referred to raspberry pi GPIO Pins guide and the wiring was as follows
IR Sensor module
VCC to 3v3
GND to GND
OUT to GPIO 19
LED
GND to GND
+ve connected with 330ohm resistor to GPIO 26
For the programming part i have used python language so i have started by importing RPI.GPIO in order to use the GPIO of the RPI and import time in order to use the time related functions.
then used GPIO.setup in order to define the pins of the sensor and led and whether they are an input and output devices.
in the while true loop i have used an if statement if the input sensor detects a high signal the LED gets turned off and if its low the LED get turned off.
Try and fails:
The first problem i have faced with the assignment was getting a warning to add GPIO.setwarnings(false) to ignore any error with the GPIO Pin
2nd try was the IR sensor was needing a 5V in order to work and this will needs a voltage divider circuit but fortunately it worked with 3v3 pin but the range was a bit low than the usual.
What I learned this week is...
Introduction and going through RPi hardware
how to use python and GPIO pins of the Raspberry Pi
Linux Basics
Use GPIO pins from Python as a programming language