<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <link href="https://funduinoshop.com/en/blog/raspberry-pi/?sAtom=1" rel="self" type="application/atom+xml" />
    <author>
        <name>Funduinoshop</name>
    </author>
    <title>Blog / Atom Feed</title>
    <id>https://funduinoshop.com/en/blog/raspberry-pi/?sRss=1</id>
    <updated>2026-05-17T21:48:48+02:00</updated>
    
        <entry>
            <title type="text">Button on the Raspberry Pi</title>
            <id>https://funduinoshop.com/en/blog/raspberry-pi/button-on-the-raspberry-pi</id>
            <link href="https://funduinoshop.com/en/blog/raspberry-pi/button-on-the-raspberry-pi"/>
            <summary type="html">
                <![CDATA[
                
                                            In the first examples we got to know the GPIO pins as outputs, which we switched to HIGH to let an LED light up. But GPIO stands for General Purpose Input/Output. So you can also use the pins as input....
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                  In the first examples we got to know the GPIO pins as outputs, which we switched to HIGH to let an LED light up. But GPIO stands for General Purpose Input/Output. So you can also program the pins as input. Then it can be determined whether there is a voltage at the input (HIGH) or not (LOW). The Raspberry Pi has only digital inputs (a workaround for measuring analog voltages we will get to know later), nevertheless the applied voltage does not have to be exactly 3.3V to be recognized as HIGH, and not 0V to be recognized as LOW. Up to about 1.4V is recognized as LOW, everything above 1.9V is surely recognized as HIGH. The only problem is the small range around ½ of 3.3V and a free pin with nothing connected to it.  
  We will get to know several digital sensors which should trigger an alarm or a certain action in our program (e.g. motion detector). The simplest of these sensors is the button, a spring-loaded switch that closes a circuit when the button is pressed and opens it again when the button is released.  
  If we connect one contact of the button to a GPIO pin and the other to 3.3V, the signal HIGH is clearly detected when the button is pressed. The problem starts after the button is released. What is the state of the GPIO then? An undefined one! You can&#039;t program with it. In the switched off state the GPIO should be permanently at GND potential. But this would lead to a short circuit when the button is pressed. Remedy is a resistor, which must be so large that only a small current flows. Resistors of 4.7 k&amp;nbsp;(=4700 ohms) or 10 kΩ&amp;nbsp;(=10,000 ohms) are common. These resistors are called pull-down resistors.  
  But you can also program the GPIO so that it normally indicates HIGH and recognizes the key press against GND as a change to LOW. Then the resistor is called pull-up resistor. And to make it even more confusing for beginners, the Raspberry Pi GPIOs have an internal pull-up or pull-down resistor that can be enabled or disabled in the program. Fortunately, this makes the initial circuits very simple.  
  The circuit diagram: Push button on the Raspberry Pi  
     
     
  The program code: Push button on the Raspberry Pi  
  from gpiozero import LED, Button
from signal import pause
led = LED (12 )
 button  = Button (16 )
 button  .when_pressed  = led .on 
 button  .when_released  = led. off 
  pause  ()    
   From the module gpiozero, the classes LED and button are imported, separated by commas, then the objects led and button are instantiated with their respective GPIO numbers.     Instead of the    sleep()   -Function from the module    time   &amp;nbsp;module,    pause   &amp;nbsp;from the module    signal   &amp;nbsp;sleep() would mean complete standstill, the keystroke would not be noticed in the time. Without pause() the program would terminate and nothing would happen.     The instantiation of button was very simple, because we only specified the GPIO number and otherwise used the default settings (see class definition next line). If you want to deviate from this, you have to enter additional parameters as keyword arguments.   
   class  gpiozero .Button  (pin , *,  pull_up=True ,  active_state=None ,  bounce_time=None ,
 hold_time=1 ,  hold_repeat=False ,  pin_factory=None )  
   More details about gpiozero can be found      here     .    
  Extension of the experimental setup: A traffic light cycle is to be started with a Raspberry Pi when a button is pressed.  
  The experimental setup is based on the first example. Instead of a LED, the LED traffic light is used. This has built-in series resistors. We instantiate three LED objects and define a function trafficLight, which is called when a button is pressed.  
  The program code: Traffic light cycle on Raspberry Pi   
  from gpiozero  import  LED, Button
from signal  import  pause
from time  import  sleep
redled = LED (16 )
yellowled = LED (20 )
greenled = LED (21 )
button = Button (12 )
def trafficLight():
       redled.on()
    sleep(1)
    yellowled.on()
    sleep(1)
    greenled.on()
    redled.off()
    yellowled.off()
    sleep(1)
    yellowled.on()
    greenled.off()
    sleep(1)
    redled.on()
    yellowled.off()
    sleep(1)
    redled.off()
button.when_pressed = trafficLight
pause()  
  Extension: Reaction game with two buttons on Raspberry Pi  
   You need two buttons, a buzzer and a red and a yellow LED. After starting the Reaction Game, the yellow LED lights up first. With    time = uniform(5, 10)   &amp;nbsp;the red LED lights up after a random time between five and ten seconds. Then two players can each press their button as fast as possible. Whoever presses too early will be caught cheating, the buzzer will sound for half a second.   
  The program code: Reaction buzzer with two buttons on the Raspberry Pi   
   #! /usr/bin/python3 
 # Reaction Game - push button, when red LED lights-up 
 # based on gpiozero documentation, Basic Recipes 
 # enhanced to recognize cheating by Bernd Albrecht 
 # Red LED lights-up 5 - 10 sec after the yellow LED 
 from  gpiozero  import  Button, LED, Buzzer
 from  time  import  sleep
 from  random  import  uniform
 from  sys  import  exit
led_red = LED (16 )
led_yellow = LED (20 )
buzzer = Buzzer (12 )
player_1 = Button (23 )
player_2 = Button (18 )

led_yellow .on ()
time = uniform (5 ,  10 )
sleep(time)
 if  player_1.is_pressed:
    print ( &quot;Player 1 is cheating!&quot; )
    buzzer .on ()
    sleep (0.5 )
    buzzer .off ()
    led_yellow .off ()
    exit()
 if  player_2.is_pressed:
    print ( &quot;Player 2 is cheating!&quot; )
    buzzer .on ()
    sleep (0.5 )
    buzzer .off ()
    led_yellow .off ()
    exit()
led_red .on ()
led_yellow .off ()
 while  True:
    if  player_1.is_pressed:
        print ( &quot;Player 1 wins!&quot; )
        break 
    if  player_2.is_pressed:
        print ( &quot;Player 2 wins!&quot; )
        break 
led_red .off ()  
                ]]>
            </content>

                            <updated>2022-07-27T14:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">RGB LED on the Raspberry Pi</title>
            <id>https://funduinoshop.com/en/blog/raspberry-pi/rgb-led-on-the-raspberry-pi</id>
            <link href="https://funduinoshop.com/en/blog/raspberry-pi/rgb-led-on-the-raspberry-pi"/>
            <summary type="html">
                <![CDATA[
                
                                             An RGB LED is the combination of three LEDs of different colors in one housing. The term RGB refers to the colors &quot;red&quot;, &quot;green&quot; and &quot;blue&quot;. The respective LEDs can be controlled with pulse width modulation (PWM)....
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 Controlling a RGB LED with a Raspberry Pi microcontroller 
 What is an RGB LED anyway? 
 An RGB LED is the combination of three LEDs of different colors in one package. Behind the name RGB are the colors &quot;red&quot;, &quot;green&quot; and &quot;blue&quot;. The respective LEDs can be controlled with pulse width modulation (PWM). Thus a multitude of color combinations is possible. 
 An RGB LED has four legs, one for each color and one common for all three colors. The longest of the four legs is the common anode (+) or cathode (-), depending on the version. The single leg next to this longest one is the connection for the red component. The green and blue parts are controlled by the legs on the other side.    
 Which type of RGB-LED you have, common anode or common cathode, is not visible from the outside. Fortunately you can&#039;t damage anything by trial and error. In blocking direction the RGB-LED does not shine. Important: Also the three implemented LEDs need series resistors. If you want to do it academically, you can calculate different series resistors from the respective flux voltages. For simplicity, you can also use equal resistors between 100 and 330 Ω (Ohm). 
 Version a: &quot;Common cathode&quot; - The longest leg of the LED is &quot;-&quot; and the three shorter legs are driven at the GPIOs with &amp;nbsp;&quot;+&quot; (voltage). 
 Version b) &quot;Common anode&quot; - The longest leg of the LED is &quot;+&quot; and the three shorter legs are controlled with &quot;-&quot; (GND) at the GPIOs. 
 By mixing the colors, many more colors can be created. For example, driving the colors &quot;blue&quot; and &quot;green&quot; produces the color &quot;turquoise&quot;, red and green produces yellow, red and blue produces magenta, and all three colors with equal amounts produce white. 
       The circuit diagram: RGB LED on the Raspberry Pi   
 The program code: RGB LED on the Raspberry Pi 
 Example program for a RGB LED with common cathode: 
 from gpiozero  import  RGBLED
from time  import  sleep
 led  = RGBLED (red=14,   green=15,   blue=18) 
 duration  =  2 

 # slowly increase intensity of all colors (5sec) 
for n  in  range (100 ):
    led .blue  =  n/100 
    led .red  =  n/100 
    led .green  =  n/100    
    sleep (0.05 )
led .color  = (0 ,  0 ,  0 )  # off 
sleep(duration)
led .red  =  1   # full red 
sleep(duration)
led .red  =  0.5   # half red 
sleep(duration)
led .color  = (1 ,  1 ,  0 )  # yellow 
sleep(duration)
led .color  = (0 ,  1 ,  0 )  # full green 
sleep(duration)
led .color  = (0 ,  1 ,  1 )  # cyan 
sleep(duration)
led .color  = (0 ,  0 ,  1 )  # full blue 
sleep(duration)
led .color  = (1 ,  0 ,  1 )  # magenta 
sleep(duration)
led .color  = (1 ,  1 ,  1 )  # white 
sleep(duration)
led .color  = (0 ,  0 ,  0 )  # off 
sleep(duration) 
 Later we will see how to use three potentiometers to set the color components. But for this we need an external analog to digital converter, because the Raspberry Pi only knows digital signals - HIGH or LOW. 
    
                ]]>
            </content>

                            <updated>2022-07-19T09:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Pulsating LED on the Raspberry Pi (pulse width modulation)</title>
            <id>https://funduinoshop.com/en/blog/raspberry-pi/pulsating-led-on-the-raspberry-pi-pulse-width-modulation</id>
            <link href="https://funduinoshop.com/en/blog/raspberry-pi/pulsating-led-on-the-raspberry-pi-pulse-width-modulation"/>
            <summary type="html">
                <![CDATA[
                
                                            An LED is said to become pulsatingly brighter and darker. (Also called &quot;fade&quot;, after the verb to fade). We would like to implement this with the so-called pulse width modulation...
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 An LED is said to become pulsatingly brighter and darker. (Also called &quot; fade &quot;, after the English verb  to fade  =  to fade  away,  to  decrease). We would like to implement this with the so-called pulse width modulation. More information about pulse width modulation on the Raspberry Pi can be found a bit further down.  In the first step, let&#039;s take a look at the schematic. 
 The schematic: Pulsating LED on the Raspberry Pi (PWM) 
   
  To vary the brightness of a LED, it is not enough to vary the voltage. Due to the design (diode!) a certain minimum voltage is needed; this so-called forward voltage is between approx. 1.6 and approx. 3 V, depending on the color of the LED. Above this forward voltage the LED becomes conductive, the current is limited by a series resistor. So: Unlike incandescent lamps, the brightness is not regulated by the voltage level. By the way, the GPIO pins deliver only exactly 3.3V anyway. 
 The remedy here is pulse width modulation (PWM). Here, the DC voltage is switched on and off with high frequency. The total transmitted energy is determined by the ratio of the duty cycle to the total duration of a cycle. This duty cycle can be between 0 and 100%. 
 On the Raspberry Pi you can use the software PWM on all GPIO pins. But there are also two special hardware PWM pins. Let&#039;s go! 
 The first program code: Pulsating LED on Raspberry Pi with pulse width modulation 
  # We start with importing the program modules 
import RPi.GPIO as GPIO  # Attention: Note the notation: small i 
import  time 
GPIO.setmode(GPIO.BCM)  # We set the mode to BCM 
 LED=23   # The word &quot;LED&quot; now stands for the number &quot; 23 &quot;. 
GPIO.setup(LED,GPIO.OUT) # &quot;  LED&quot; (pin  23 ) is an output .
Dimmer = GPIO.PWM(LED ,100 )  # We set the LED as PWM with a frequency of  100  
Dimmer.start (0 )  # Dimmer is started 
 # Here starts the loop 
 try :
    while   True :  #while loop so that the program runs continuously 
        for  dc  in  range (0  ,101  ,5 ):          # loop of the duty cycle in  steps of 5.  
             Dimmer.ChangeDutyCycle(dc)  # change the duty cycle of the dimmer. 
            time  .sleep  (0.1 )  # Wait  0.1  second .
        for  dc  in  range (100 , -1 , -5 ):      # Loop the duty cycle in steps of -5 . 
            Dimmer.ChangeDutyCycle(dc)  # Change the duty cycle of the dimmer. 
            time  .sleep  (0.1 )  # Wait  0.1  second. 
except KeyboardInterrupt:  # With CTRL+C we interrupt the program 
    print (&quot;Finished&quot;)  # Write &quot;Finished&quot; in the shell window 
    Dimmer .stop ()  # Stop the dimmer. 
    GPIO.cleanup()  # End the program.  
 In this example we will learn another form of loop: the for loop. This command line also ends with a colon followed by indentation of the lines to be repeated. 
 The variable dc (for duty cycle) is incremented in the range 0 to exclusively 101 in increments of five:  for dc in range(0,101,5) : 
 The second for loop counts down from 100 to -1 by -5:  for dc in range(100,-1,-5) : 
 The second program code: Pulsing LED on Raspberry Pi with pulse width modulation using gpiozero command    
 # We start with importing the program modules
from gpiozero import PWMLED
import time
pwmled = PWMLED (23 ) # optional  parameter  frequency=xxx  (default 100) 

# here  starts the loop 
try:
    while  True: # while loop so that the program  runs   continuously 
        for  dc in range(0,101,5):   #  increment the tasgrad in steps of 5. 
            pwmled.value  = (  dc/100 ) # change the duty cycle (between  0  and  1 ) of the dimmer.
            time .sleep  (0.1 ) # Wait  0.1  second.
        for  dc in range (100  ,-1  ,-5 ): # Count down the duty cycle in   steps of -5. 
            pwmled.value = (dc/100 ) #  Change the duty cycle (between 0 and 1) of the dimmer. 
            time.sleep(0.1) # Wait  0.1 second .

except  KeyboardInterrupt: # With CTRL+C we interrupt the program 
    print  (  &quot;Finished&quot;  ) # Write  &quot; Finished &quot;  in the shell window 
# pwmled.value  = 0 # 1. method to  clear the LED at program end 
    pwmled.close()  # 2nd method to clear the LED at program end  
 Overall, the program code is leaner with gpiozero. 
 Please note: The duty cycle is between 0 and 100%. While the duty cycle argument for RPi.GPIO is the % value, gpiozero expects the value as floating  point &amp;nbsp;number between 0.0 and 1. 0, so instead of 50 [%] 0.5. 
                ]]>
            </content>

                            <updated>2022-06-17T10:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Connect buzzer and LED to the Raspberry Pi</title>
            <id>https://funduinoshop.com/en/blog/raspberry-pi/connect-buzzer-and-led-to-the-raspberry-pi</id>
            <link href="https://funduinoshop.com/en/blog/raspberry-pi/connect-buzzer-and-led-to-the-raspberry-pi"/>
            <summary type="html">
                <![CDATA[
                
                                            In this blog post we want to make a buzzer and an LED light up and sound respectively with the help of a Raspberry Pi microcontroller. This program is often used in schools to demonstrate the...
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 Note: An active buzzer is required for this program (explanation follows later), attention must be paid to polarity. No series resistor is needed at the buzzer (speaker). 
 In this blog post we want to make a buzzer and an LED light up and sound respectively using a Raspberry Pi microcontroller. This program is popular in schools for showing how simple output signals can be utilized using a Raspberry Pi with simple components.  Before we get into what the difference is between an active and passive speaker, let&#039;s first look at the schematic and program code. 
 The schematic: Connecting buzzer and LED to the Raspberry Pi 
   
 The source code: Connecting Buzzer and LED to the Raspberry Pi 
  # This time we also use the first program section. Here variables are entered. This means that there is a number behind a letter or a word. In our case, the LED is connected to pin 23 and the piezo speaker to pin 4. To avoid confusing the two pins later, we simply rename pin 23 and pin 24. 
 # We start with importing the program modules 
 import  RPI.GPIO  as  GPIO
 import  time
GPIO.setmode(GPIO.BCM)  # We set the mode to BCM 
 LED=23 ;  # The word &quot;LED&quot; now stands for the number &quot;23&quot;. 
 Beeps=24 ;  # The word &quot;beep&quot; now stands for the number &quot;24&quot;. 
GPIO.setup(LED,GPIO.OUT)  # Pin &quot;LED&quot; (pin 23) is an output .
GPIO.setup(Pieps,GPIO.OUT)  # Pin &quot;Pieps&quot; (Pin 24) is an output 
 # Here starts the loop 
 try :
 while   True :  # While loop so that the program runs continuously 
GPIO.output(LED,GPIO.HIGH)  # Turns on the LED .
GPIO.output(Pieps,GPIO.HIGH)  # Turns on the piezo speaker. 
time.sleep (1 )  # Wait 1 second 
GPIO.output(LED,GPIO.LOW)  # Turns off the LED .
GPIO.output(Pieps,GPIO.LOW)  # Turns off the piezo speaker .
time.sleep (1 )
 # Here at the end the program jumps to the start of the while loop. So it&#039;s about to beep and light up again. If you increase or decrease the pause (time.sleep), it will beep and light faster or slower. 
 except  KeyboardInterrupt:  # With CTRL+C we interrupt the program 
 print  (&quot;Finished&quot;)  # Write &quot;Finished&quot; in the shell window 
GPIO.cleanup()  # Exit the program  
 Difference active and passive buzzer 
 The active buzzer has a built-in oscillator, which produces a  buzzing  sound when the voltage of 3.3V or 5V is applied. Due to the design, you have to pay attention to the polarity of the buzzer. At delivery, these buzzers usually have a small sticker with the plus sign and &quot;REMOVE SEAL AFTER WASHING&quot; sticker. There is also a plus + again on the body of the part itself. You have to look twice to see the longer leg. Or you take a small breakout board; here the contacts are marked with S (stands for signal) and - (minus, ground).&amp;nbsp; 
 You can test the buzzer with a simple program like for the blinking LED, where the (almost) arbitrary pin is switched to HIGH for one second and to LOW for one second. 
 The passive buzzer has no built-in oscillator, so the Raspberry Pi has to take over this function. If you try the above program on a passive buzzer, you will hear a soft &quot;click&quot; sound every second. However, if you shorten the pause time extremely (sleep(0.001) or sleep(0.002)) and repeat the on/off for a certain duration, you can hear a sound whose frequency we can easily calculate: one millisecond each of HIGH or LOW means (neglecting the execution time of the other commands) about 500 cycles on/off per second, i.e. about 500Hz. 
 If you want to emit a short warning tone, you should use an active buzzer, which is switched on and off like an LED. Attention should be paid to the polarity. 
 If you want to program a two-tone siren (which can be heard more clearly) or a short recognition melody (jingle), you should use a passive buzzer or a small loudspeaker. 
    
 &amp;nbsp; 
 &amp;nbsp; 
                ]]>
            </content>

                            <updated>2022-06-15T15:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Alternately flashing LEDs on the Raspberry Pi microcontroller</title>
            <id>https://funduinoshop.com/en/blog/raspberry-pi/alternately-flashing-leds-on-the-raspberry-pi-microcontroller</id>
            <link href="https://funduinoshop.com/en/blog/raspberry-pi/alternately-flashing-leds-on-the-raspberry-pi-microcontroller"/>
            <summary type="html">
                <![CDATA[
                
                                            It is also possible to connect the electronic components on the breadboard without a T-Cobbler. But then you need a jumper wire of the type female - male for the connection to the J6 connector strip of the Raspberry Pi...
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 How to make two LEDs flash alternately on the Raspberry Pi? 
 You can connect the electronic components on the breadboard without a T-Cobbler. But then you need a jumper wire of type female - male for the connection to the J6 header of the Raspberry Pi, i.e. female for the Raspberry Pi and male for the breadboard. 
   
  The program code (alternately blinking LED on the Raspberry Pi)   
  # From here the code can be copied directly into the Python software. 
 # Black, colored = code and gray = explanations 
 #We start with importing the program modules 
import RPI.GPIO  as  GPIO
import  time 
GPIO.setmode(GPIO.BCM)  #We set the mode to BCM 
GPIO.setup (23 ,GPIO.OUT)  #Pin 23 is an output. 
GPIO.setup (24 ,GPIO.OUT) #Pin   24 is an output .
 # The loop starts here 
 try :
    while  True:  #While loop so that the program runs continuously 
        GPIO.output (23 ,GPIO.HIGH)  # Turns on the LED at pin 23 .
        GPIO.output (24 ,GPIO.LOW)  # Turns off the LED at pin 24 .
        time .sleep (1 )  # Wait 1 second 
        GPIO.output (23 ,GPIO.LOW)  # Turns off the LED on pin 23 .
        GPIO.output (24 ,GPIO.HIGH)  # Turns on the LED on pin 24 .
        time .sleep (1 )
 # Here at the end the program jumps to the start of the loop part. So.. 
 # ...switch on the LED at pin 23. 
 # ... etc... etc... etc.. 
except KeyboardInterrupt:  # With CTRL+C we interrupt the program 
    print ( &quot;Finished &quot;) # Write &quot;Finished&quot; into the shell window
    GPIO.cleanup() # Exit the program
  
 In example no. 01 Blinking LED we had implemented the infinite loop with while True and indentation of the following code lines. If you aborted this infinite loop with the key combination Ctrl-C, you will have noticed that firstly you get an error message and secondly the LED may still be on. To prevent these two unwanted effects, some lines of code have been added to this example. Before the while True loop the line  try:  is inserted. The colon leads to the indentation of the whole loop. If an error occurs in this loop while the program is running, there is no error message, but the program is continued at  except KeyboardInterrupt: . With the print command, the end of the program is output in the Python shell (lower window at Thonny), with GPIO.cleanup(), the GPIOs (i.e. our LEDs) are switched off and released for other purposes. 
 Example: Traffic light cycle on Raspberry Pi 
 Here is a proposed solution for a traffic light cycle using the module gpiozero: 
   
   
   
                ]]>
            </content>

                            <updated>2022-06-06T08:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Flashing LED on Raspberry Pi microcontroller</title>
            <id>https://funduinoshop.com/en/blog/raspberry-pi/flashing-led-on-raspberry-pi-microcontroller</id>
            <link href="https://funduinoshop.com/en/blog/raspberry-pi/flashing-led-on-raspberry-pi-microcontroller"/>
            <summary type="html">
                <![CDATA[
                
                                            Unlike the Arduino, the Raspberry Pi does not have access to the built-in LEDs. They only indicate power supply and access to the µSD card. To make an LED blink, an external LED with a power supply is needed....
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 How to make a LED blink on the Raspberry Pi? 
  Unlike the Arduino, you don&#039;t have access to the built-in LEDs on the Raspberry Pi. They only show power supply and access to the µSD card.  
 To make a LED blink, you need an external LED with a suitable series resistor and jumper cables. The most sensible way is to build the circuit on a breadboard with a T-Cobbler. This kind of arrangement also facilitates later experiments with several LEDs, pushbuttons and sensors. The programming is done in the programming language Python. 
 The circuit diagram (blinking LED on Raspberry Pi) 
   
 What is an LED? 
 LED stands for Light Emitting Diode. The last word indicates the electronic properties. A diode is a semiconductor that lets the current through only in one direction, and blocks it in the other direction. The two &quot;legs&quot; are called anode and cathode. If you look closely, you can see that the legs are of different lengths. The positive voltage is applied to the longer leg, the anode; the shorter leg, the cathode, is connected to ground via a resistor. The resistor is necessary because of another property of diodes. First of all, a minimum voltage is required for any current to flow at all: This is called forward voltage. At higher voltages the diode becomes fully conductive. Therefore you need a series resistor to limit the current, because the pins of the micro controllers and also of the Raspberry Pi should be charged with a maximum of 15 to 20 mA. We use series resistors in the range of 100 to 330 Ω (Ohm). 
 The programming language Python can be extended by program modules, similar to C/C++ with libraries. For our blinking LED we need two of these modules: first &quot;time&quot; to set the blinking duration. And secondly a module to access the GPIOs (General Purpose Input/Output). 
 How do I control an LED with a Raspberry Pi? 
 Importing the modules is done at the beginning of the Python program; you have several options to do this. Examples: 
 The following line imports the module  time : 
  import   time  
 When calling the method  sleep  , the module name  time  must be prefixed with a dot: 
  time  .sleep  (1 ) 
 In contrast to delay(), where the time interval is specified as argument in milliseconds,  time.sleep()  specifies the values in seconds, possibly with decimal point. 
  import  RPi.GPIO  as  GPIO 
 This simplifies the calls to the methods in the program, e.g. 
  GPIO  .setmode  (GPIO  .BCM ) 
 Third example for another module for GPIO access: 
 from gpiozero  import  LED 
 From the module  gpiozero  only the class LED is imported. With this import method, the module name is no longer prepended when the method/function is called. 
 Example programs to control a LED with a Raspberry Pi microcontroller 
 First example with the module RPi.GPIO: 
 import RPi.GPIO as GPIO
import  time 
GPIO.setmode(GPIO.BCM) # pin name for Broadcomm processor 
GPIO.setup (26 ,GPIO.OUT) # GPIO26 (=phys. pin 37) becomes output 

 while  True: # endless loop, abort with Ctrl-C 
    GPIO .output  (26  ,1 ) # GPIO 26 is switched HIGH 
    time  .sleep  (1 )
    GPIO .output  (26  ,0 ) # GPIO 26 is switched LOW 
    time  .sleep  (1 )
 
 Second example with the module gpiozero. Only  LED  and  sleep  are imported. 
  from  gpiozero import LED
 from   time  import  sleep 
redLED = LED (26 ) # redLED is instantiated at GPIO  26  

 while   True :
    redLED.on() # redLED is switched on 
    sleep  (1 )
    redLED.off() # redLED is  switched off 
    sleep  (1 )
 
 Challenge: Extend circuit and program for a traffic light cycle, e.g. red(3s), red/yellow(1s), green(3s), yellow(1s), restart with red. 
 Suggested solution see no. 02 The alternating blinker 
                ]]>
            </content>

                            <updated>2022-06-01T00:45:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Getting Started with the Raspberry Pi - Part 3: Programming</title>
            <id>https://funduinoshop.com/en/blog/raspberry-pi/getting-started-with-the-raspberry-pi-part-3-programming</id>
            <link href="https://funduinoshop.com/en/blog/raspberry-pi/getting-started-with-the-raspberry-pi-part-3-programming"/>
            <summary type="html">
                <![CDATA[
                
                                            Basically, you can also install the Arduino IDE on the Raspberry Pi or use the pre-installed program Geany, a very functional editor, in different programming languages....
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 In principle, you can also install the Arduino IDE on the Raspberry Pi or program in different programming languages with the pre-installed program Geany, a very functional editor, but the Raspberry Pi takes its name from the Python programming language; originally it was only planned as a  Python   interpreter . So: Who says programming the Raspberry Pi, usually means the very widely used and easy to learn language Python. 
 In the last few years, the program Thonny has established itself as an Integrated Development Environment (IDE) for Python  programs . 
 &amp;nbsp;  
 One differentiates basically the editor in the upper part of the window, here the programs are written, and the Shell in the lower part, here the programs with possible inputs and outputs run. One can enter however also in the Shell directly short commands. 
 Advanced programmers should click on &quot;Switch to regular mode&quot; in the upper right corner of the screen to get the menu bar displayed as well. 
 &amp;nbsp;  
 If you want to learn the programming language autodidactically, you can do this with the help of a lot of books. At this point the method &quot;learning by doing&quot; is recommended, i.e. simply copy the program examples. Mostly the program code is self-explanatory. That is the beauty of Python. 
 In order to avoid unnecessary frustration, a few rules should be mentioned at this point, which are primarily aimed at those switching from Arduino C/C++: 
 The variable type does not have to be declared, in contrast to C/C++. Python recognizes the type the first time it is used. For example, if you type  (&quot;abc&quot;)  in the shell, you get &amp;lt;class &#039;str&#039;&amp;gt; as output; so the type string is recognized because of the apostrophes. 
 The command line is not terminated with a semicolon. Instead, Python requires careful attention to indentation. So: every command always starts at the first position of the paragraph. 
 Indentations (usually tab=four spaces) are done (mostly automatically) for branches, loops or self-defined functions, if necessary several times. 
 Program and variable names always start with a letter or the underscore _. After that, numbers can also be used. The underscore is the only special character allowed and is mostly used for special purposes. 
 As said before: More explanations about Python with the program examples. 
                ]]>
            </content>

                            <updated>2022-05-24T11:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Getting Started with the Raspberry Pi - Part 2: Hardware and Software</title>
            <id>https://funduinoshop.com/en/blog/raspberry-pi/getting-started-with-the-raspberry-pi-part-2-hardware-and-software</id>
            <link href="https://funduinoshop.com/en/blog/raspberry-pi/getting-started-with-the-raspberry-pi-part-2-hardware-and-software"/>
            <summary type="html">
                <![CDATA[
                
                                            A short introduction to the most important components for the Raspberry Pi. Whether plug-in cable, resistor or LED, we show you which components you need to get started. In addition, we go into the installation of the software for the Raspberry Pi and...
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                 Hardware and Software for the Raspberry Pi 
 Hardware for the Raspberry Pi 
     
 Basic accessories for the Raspberry Pi 
 In addition to sensors and actuators, you need&amp;nbsp; plug-in cables &amp;nbsp;in connection with a&amp;nbsp; breadboard as a basis for fast and flexible experimental setups. This saves time-consuming soldering work. Furthermore&amp;nbsp; light emitting diodes &amp;nbsp;are very suitable to check the signal output of the board. 
 The Breadboard 
 A breadboard is a good tool to build circuits without soldering. In a breadboard there are always several contacts connected in a row. Therefore, many cables can be connected to each other at these points without soldering or screwing. 
 The following picture shows in color which contacts are connected to each other. 
 &amp;nbsp;  
 Standard plug-in board for Raspberry Pi and microcontroller.   The green lines in the picture show the course of the traces. 
 For a good connection of the Raspberry Pi to the breadboard there are so called T-Cobbler with a ribbon cable leading out all 40 pins. 
   
 Light emitting diode (LED) for the Raspberry Pi 
 LEDs are a very fast way to test the results of a project. Therefore they are useful for almost all Arduino projects. You can read a lot about LEDs on the net. Here are only the most important infos. 
   
 
 The current can only flow through the LED in one direction. Therefore it must be connected correctly. A LED has a longer and a shorter contact. The longer contact is + and the shorter one is -. 
 An LED is designed for a certain voltage. If this voltage is undershot, the LED lights up less brightly or it remains off. However, if the voltage is exceeded, the LED burns out very quickly and becomes very hot at the contacts (CAUTION!). 
 Typical voltage values according to LED colors: Blue:3.1V, White:3.3V, Green:3.7V, Yellow:2.2V, Red:2.1V The voltage at the board&#039;s Digital Ports is 5V. When connected directly to these ports, each LED gives up the ghost quite fast. Therefore a resistor must be connected into the circuit. In the internet you can find very good help under the search term &quot;Widerstandsrechner LED&quot;. 
 Non-binding recommendation for resistors at the following LEDs (When connected to the 5V pins of the microcontroller board.   
 
 
 
 
 LED 
 White 
 Red 
 Yellow 
 Green 
 Blue 
 Infrared (IR) 
 
 
 Resistance 
 100 Ohm 
 200 Ohm 
 200 Ohm 
 100 Ohm 
 100 Ohm 
 100 Ohm 
 
 
 
 &amp;nbsp; 
 Plug-in cable or jumper wire for the Raspberry Pi 
 The jumper wires are available in different versions, mostly in 10cm or 20cm length with plugs as well as with sockets. Here mm=male-male=plug on both sides, mf=male-female=plug on one side, socket on the other side, and ff=female-female= with sockets on both sides. 
   
 Pushbuttons and switches for the Raspberry Pi 
 The first and simplest sensor is the button, a spring-loaded switch that reopens the electrical contact when released. 
   
 Software for the Raspberry Pi 
 The operating system Raspberry Pi OS can be downloaded for free from the  homepage of the Raspberry Pi Foundation . The 32-bit version is currently identical for all models. For writing to the µSD card (8 to 32 GB) on the PC, the program Imager is recommended, which can also be downloaded from the Foundation&#039;s homepage. 
 Installing the software 
   
 Starting up the Raspberry Pi 
 At the first startup the operating system is set up. Among other things, the access data for the home WLAN is entered. Since spring, the user name pi is no longer used automatically, but you are asked to enter a user name and a password. After a restart at the end of the initialization, a graphical user interface starts. This process takes a little longer than a minute. 
 When clicking on the icon, one is asked if one only wants to have the possible updates displayed or if one wants to start them directly. 
 The following screenshot was taken with the pre-installed program &quot;scrot&quot; (for  screen  shot ). 
 &amp;nbsp;  
                ]]>
            </content>

                            <updated>2022-05-22T12:00:00+02:00</updated>
                    </entry>

    
    
        <entry>
            <title type="text">Getting Started with the Raspberry Pi - Part 1</title>
            <id>https://funduinoshop.com/en/blog/raspberry-pi/getting-started-with-the-raspberry-pi-part-1</id>
            <link href="https://funduinoshop.com/en/blog/raspberry-pi/getting-started-with-the-raspberry-pi-part-1"/>
            <summary type="html">
                <![CDATA[
                
                                            This guide is intended to serve as a foundation for learning the Raspberry Pi OS with a focus on the Python programming language. It is intended to provide beginners with a simple, interesting and closely guided introduction to...
                                        ]]>
            </summary>
            <content type="html">
                <![CDATA[
                  What actually is &quot;Raspberry Pi&quot;?  
 This tutorial is intended to serve as a basis for learning the Raspberry Pi OS with a focus on the Python programming language. It is intended to give beginners a simple, interesting and closely guided introduction to the topics &quot;Computational Thinking&quot; and &quot;Physical Computing&quot;. The tutorial is mainly oriented towards practical tasks with a theoretical introduction beforehand. It is essential to read this beforehand in order not to fail in the later practical tasks due to trivialities. 
 This manual was developed in the context of a teaching activity. It can be used free of charge to learn the basics about Raspberry Pi computers, but cannot be copied or used in any other way without permission. The tutorial has been carefully created and is continuously maintained, but no guarantee is given for its correctness and completeness. 
 For the practical tasks you should be provided with some electronic components. On the website funduinoshop.de you can order suitable sensor sets, which are specially designed for these instructions. 
 The Raspberry Pi with meanwhile a variety of different models is in contrast to the micro controller (e.g. Funduino Uno or Nano) a real computer with a Linux-based operating system (Raspberry Pi OS, formerly Raspbian). The operating system as well as application programs and data are located on a µSD card (8 to 32 GB), which is loaded at startup. The most important interfaces are first the USB sockets for keyboard and mouse as well as the HDMI interface(s) to the monitor.    
 Raspberry Pi B (2012) 
 The great success of the Raspberry Pi is based both on programming with the widely used Python programming language and on the possibility of connecting electronic components to the 40-pin J6 header (often called GPIO header). This is identical for all models since 2014. When it comes to nomenclature, you have to be careful whether you mean the physical pin (in the picture on the left the odd numbers from 1 to 39, on the right the even numbers from 2 to 40) or the GPIO designation. For example, the physical pin 11 corresponds to GPIO17 (General Purpose Input Output connector 17 of the processor). GPIOs are therefore digital inputs or outputs, as in the case of the micro controller. 
   
 Figure J6 header: 40 pins, of which 2x3.3V, 2x5V, 8xGround, 26xGPIOs, 2 reserved 
  Some of the pins have a secondary assignment as electronic interface, e.g. One Wire at pin 7, I2C (= Inter-Integrated Circuit) at pins 3 and 5, UART (= Universal Asynchronous Receiver and Transmitter) at pins 8 and 10 and SPI (=Serial Peripheral Interface) at pins 19, 21, 23 and 24 or 26. This secondary assignment is defined in the operating system in the Raspberry Pi configuration. More about this in the respective examples. 
                ]]>
            </content>

                            <updated>2022-05-19T13:30:00+02:00</updated>
                    </entry>

    
</feed>
