Investigation GPIOs on modular embedded board


Investigate GPIOs on Modular Embedded Board


Contents

  1. Background

  2. GPIO

  3. “Traffic Light” work with the board


Background

We are, at the moment not entirely sure, whether or not the I/Os on the 40 pin connector of the Modular Embedded board are actually working.

The aim of this issue is to

  • Establish for sure whether the connectors can be used for output as intended (does not necessarily have to be verified with the lightpost, any other means would be acceptable too).

  • Find out whether they are only outputs or whether they can be used as inputs as well

  • Build experience in using the GPIOs of the Modular Embedded boards.

GPIO

Our Modular Embedded Board (including Jetson general development boards)contain a 40 pin header, that each of the pins have for each purpose, similar to the 40 pin header in the Raspberry Pi.
These GPIOs can be controlled for digital input and output using the Python library provided in the Jetson GPIO Library package. Common Vision Blox: Modular Embedded - Specifications

40Pin Connector


Figure 1. Common Vision Blox: Modular Embedded - Specifications and pins

There is a representative general purpose input/output (GPIO). GPIO is a digital signal pin that can be used as an input or an output, or both. Inter-Integrated Circuit (I2C), Serial Peripheral Interface (SPI) and Universal asynchronous receiver-transmitter (UART) are different types of protocols for communication between the Embedded Board and other devices. They each have their own properties like Master/Slave-bus, Multi-Master, Multi-Connection, different Data Transfer speed and physical circuit. But in this case excluding the data transfer types it is focused on pins function through the input/output.


“Traffic Light” work with the board

Using the output test experience, it could be applied in making “Traffic Light”. This method is used not only in traffic lights, but also motor control through the PWM and measuring other sensors too. For the working, Breadboard, LED-Diode and Resistor(300 Ohm) have been used.A one side of LED-Diode is connected to ground(GND) and the other side is connected to GPIO pin.

TrafficLight_BreadBoard
Figure 7. GPIO Traffic Light Breadboard

import time
import RPi.GPIO as GPIO

# Pin Definitions
output_pin_red = 7
output_pin_yellow = 15
output_pin_green = 32

high_value = GPIO.HIGH
low_value = GPIO.LOW


def trafficLight():
    # Red->Yellow->Green Light(Output)
    GPIO.output(output_pin_red, high_value)
    GPIO.output(output_pin_yellow, low_value)
    GPIO.output(output_pin_green, low_value)
    time.sleep(3)
            
    GPIO.output(output_pin_red, low_value)
    GPIO.output(output_pin_yellow, high_value)
    GPIO.output(output_pin_green, low_value)
    time.sleep(3)
            
    GPIO.output(output_pin_red, low_value)
    GPIO.output(output_pin_yellow, low_value)
    GPIO.output(output_pin_green, high_value)
    time.sleep(3)


def blinking():
    # Green Light Blinking 
    GPIO.output(output_pin_red, low_value)
    GPIO.output(output_pin_yellow, low_value)
    GPIO.output(output_pin_green, low_value)
    time.sleep(0.3)
    
    GPIO.output(output_pin_red, low_value)
    GPIO.output(output_pin_yellow, low_value)
    GPIO.output(output_pin_green, high_value)
    time.sleep(0.3)

    GPIO.output(output_pin_red, low_value)
    GPIO.output(output_pin_yellow, low_value)
    GPIO.output(output_pin_green, low_value)
    time.sleep(0.3)

    GPIO.output(output_pin_red, low_value)
    GPIO.output(output_pin_yellow, low_value)
    GPIO.output(output_pin_green, high_value)
    time.sleep(0.3)


def main():
    # Pin Setup:
    GPIO.setmode(GPIO.BOARD)  # Board pin-numbering
    # set pin as an output pin with optional initial state of HIGH
    GPIO.setup(output_pin_red, GPIO.OUT, initial=high_value)
    GPIO.setup(output_pin_yellow, GPIO.OUT, initial=high_value)
    GPIO.setup(output_pin_green, GPIO.OUT, initial=high_value)
    
    print("Starting traffic light demo now! Press CTRL+C to exit")

    try:
        while True:
            time.sleep(1)
            trafficLight()
            blinking()
            
            
    finally:
        GPIO.cleanup()

time.sleep



if __name__ == '__main__':
    main()

Figure 8. GPIO Traffic Light Python Code

TL_Video
Figure 9. Traffic Light with LED


4 Likes