Skip to content

Instantly share code, notes, and snippets.

@krishnan793
krishnan793 / GPIO_Blink_LED.C
Last active August 29, 2015 14:16
This program will blink an LED connected to gpio23 of BeagleBoneBlack Board. Inorder for the code to work first set gpio port 23 as output. (echo 23 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio23/direction))
@krishnan793
krishnan793 / BeagleBoneBlack_PushButton_LED.C
Last active August 29, 2015 14:16
BeagleBoneBlack Push Button + LED
#include<stdio.h>
#include<unistd.h>
void Read(char *switch_value, char *val);
void Write(char *switch_value, char *val);
void Blink(char *led_value, int delay);
int main()
{
char *led_direction="/sys/class/gpio/gpio23/direction";
@krishnan793
krishnan793 / ADC_bash.sh
Last active August 29, 2015 14:16
Print ADC value
value=$(cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw)
value=$(echo $value*0.0004394 | bc)
echo "$value V"
@krishnan793
krishnan793 / view_picture.cpp
Created April 30, 2015 06:50
Program reads a picture file called boy.jpg in the current folder and displays it. After 1 second it will change to grey scale.
#include<highgui.h>
#include<cv.h>
using namespace cv;
int main()
{
Mat A,B;
A=imread("boy.jpg"); //Read the image file
namedWindow("Boy", CV_WINDOW_AUTOSIZE ); //Create a new window to show the image. Name the window as "boy"
int RED_LED = 12;
int BLUE_LED = 13;
int GREEN_LED = 14;
void setup() {
// Initialisation
pinMode(RED_LED,OUTPUT);
pinMode(BLUE_LED,OUTPUT);
pinMode(GREEN_LED,OUTPUT);