Table of Contents

datacomm Keyword 2

Identification of chosen keyword.

Raspberry Pi GPIO Programming

The Raspberry Pi hosts a General Purpose Input Output board for interfacing with low level peripherals. Dragon.net was nice enough to write a detailed C library for the GPIO to make electronics programming super easy! Here's an example of a program that turns on and off an LED:

/*
 * blink.c:
 *      Simple test program to blink an LED on pin 7
 */
 
#include <wiringPi.h>
#include <stdio.h>
 
int main (void)
{
  int pin = 7;
  printf("Raspberry Pi wiringPi blink test\n");
 
  if (wiringPiSetup() == -1)
    exit (1);
 
  pinMode(pin, OUTPUT);
 
  for (;;){
    printf("LED On\n");
    digitalWrite(pin, 1);
    delay(250);
    printf("LED Off\n");
    digitalWrite(pin, 0);
    delay(250);
  }
 
  return 0;
}

by way of this reference I hope to setup a simple c application using a solid state relay for my future automated “Dial a Coffee” via Asterisk and Pi ingenuity:http://elinux.org/RPi_Low-level_peripherals#GPIO_Driving_Example_.28C.29

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

datacomm Keyword 2 Phase 2

Identification of chosen keyword.

Lair Brew

A simple program that operates a relay switch that supplies electricity for delicious caffeinated beverages.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

Demonstration

/*
Lair_Brew ~ Caffeine ~
Version 0.2
*/
 
#include <wiringPi.h>
#include <stdio.h>
 
void loopback(void)
{
    char ch;
    ch = getchar();
    while( ch != '\n' ) ch = getchar();
}
 
int main (void)
{
    int pin = 7;
    char ch;
    int exit_flag = 0;
    printf("welcome to Lair Brew\n");
 
  if (wiringPiSetup() == -1) return(1);
 
    pinMode(pin, OUTPUT);
    printf("Brew on\n");
    digitalWrite(pin, 1);
 
 while( exit_flag  == 0 ) {
    printf("Wish to exit? (Y)\n");
    scanf(" %c", &ch );
    ch = toupper( ch );
 
 if((ch == 'Y')){
    printf("\nBrew Off\n");
    digitalWrite(pin, 0);
    delay(250);
    printf("\nEnjoy Your Coffee, Sir!\n");
  }
  else {
    printf("\nType (y) to exit.\n");
    loopback();
  }
   if( ch == 'Y' ) exit_flag = 1;
  }
 
  return 0;
}

The program is loaded into /etc/asterisk/extensions.conf like so:

exten => 607,1,Answer
exten => 607,2,Wait(1)
exten => 607,3,System(/tmp/Lair_brew_auto)
exten => 607,4,Hangup()