Raspblocks Raspberry

Raspberry Pi

Code Generator

Raspblocks Raspberry
Home Projects Start Coding


Raspberry Pi - Blink

This example shows the simplest thing you can do with a Raspberry Pi to see physical output

it' one of the classic electronic analogy to "Hello World" is to make an LED blink. Raspberry Pi has many General Purpose Input/Output pins which can be configured as input/output and turned on/off via software.In this Tutorial we will use Raspblocks to generate python code to control the LED, as coding in Raspblocks is very simple and easy yet it's very powerful.

Hardware Required

- Raspberry Pi

- LED

- 220 Ohm Resistor

Circuit

Place the LED with a 270 ohm resistor in series with the GND and GPIO pin of Raspberry Pi (use a breadboard for hassle free connection). Always use a resistor with LEDs to limit the current, else you might end up with a burnt LED ;)

Raspblocks schema button
Code - Blocks

After running the code, the LED should Blinks If not then check you code and connections and try again.

Raspblocks blocks button
Code - Python

Create new python file blink.py and enter following code. To run the code, open the terminal and go to directory where you code is located and enter the command " sudo python blink.py " and hit enter.

import RPi.GPIO as GPIO 
import time 
GPIO.setmode(GPIO.BCM) 
GPIO.setup(27 GPIO.OUT) 
 
while True: 
    GPIO.output(27,True) 
    time.sleep(500) 
    GPIO.output(27,False) 
    time.sleep(500)