Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter A - The Raspberry Pi Computer

Similar presentations


Presentation on theme: "Chapter A - The Raspberry Pi Computer"— Presentation transcript:

1 Chapter A - The Raspberry Pi Computer
Credit Card-size computer introduced in 2012 LINUX operating system Large number of reconfigurable General Purpose Input/Output digital pins (GPIO) Communication via SPI, I2C, and UART interfaces Two hardware Pulse-Width Modulation PWM channels No analog inputs-- we use an MCP3008, an 8-channel, 10 bit A/D converter for analog data

2 Specifications https://www. raspberrypi
SoC: Broadcom BCM2837 CPU: 4× ARM Cortex-A53, 1.2GHz GPU: Broadcom VideoCore IV RAM: 1GB LPDDR2 (900 MHz) Networking: 10/100 Ethernet, 2.4GHz n wireless Bluetooth: Bluetooth 4.1 Classic, Bluetooth Low Energy Storage: microSD GPIO: 40-pin header, populated Ports: HDMI, 3.5mm analogue audio-video jack, 4× USB 2.0, Ethernet, Camera Serial Interface (CSI), Display Serial Interface (DSI)

3 The Raspberrry Pi

4 Another Rpi view

5 GPIO Pinout for the RPi 3

6 GPIO Pinout for the RPi 3 Several communication protocols available:
40 unbuffered pins An incorrect connection may destroy RPi Two 5V & two 3.3V. High current applications require external source Eight Grounds 13 digital I/O pins Several communication protocols available: One I2C Two SPI One UART Two PWM

7 Accessing the GPIO Requires a special library
Will be included on your SD card Requires a directive for your code: #include <bcm2835.h> Requires a change to the build command: gcc program.c -o program -lbcm2835 Requires a change to your execution: sudo program (“sudo” stands for “super user do” )

8 Sample code – the blink.c program
// Example program for bcm2835 library // Blinks a pin on an off every 0.5 secs // Author: Mike McCauley Copyright (C) 2011 Mike McCauley // #include <bcm2835.h> // Blinks on RPi Plug P1 pin 13(which is GPIO pin 27) #define PIN RPI_BPLUS_GPIO_J8_13 int main(int argc, char **argv) { if (!bcm2835_init()) return 1; //start using GPIO; indicate if error // Set the pin to be an output bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_OUTP);

9 The blink.c program continued
// Blink forever while (1) { bcm2835_gpio_write(PIN, HIGH); // Turn pin/LED on bcm2835_delay(500); // wait ½ second bcm2835_gpio_write(PIN, LOW); // turn pin/LED off } bcm2835_close(); // signals end to use of GPIO return 0;

10 Changes to compilation and execution
First, library must be installed (this is already on your SD cards!) For build (need to link library): gcc -o blink blink.c -l bcm2835 For execute (need more authority to access GPIO): sudo ./blink (sudo - execute a command as another user)

11 Testing the code

12 Analyzing the circuit

13 Common errors Connecting to any other pin
Putting the diode in backwards No harm done – simply doesn’t light up Forgetting the resistor Very bright diode, then diode death Connecting to wrong GPIO pin or Connecting to 5V instead of ground Connecting to any other pin ????

14 Laboratory Assignment #2
This lab lasts two weeks!!! Generate and run the program “blink.” Generate and run a program that allows you to type in an integer k (0 to quit) and then have the led blink k times. Generate and run a program that allows you to type in a sentence and then have the led blink that word in Morse code (no input loop).

15 International Morse Code table


Download ppt "Chapter A - The Raspberry Pi Computer"

Similar presentations


Ads by Google