Skip to content

Instantly share code, notes, and snippets.

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);
@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"
@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 / 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 / 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))
while true
do
echo 1 > /sys/class/gpio/gpio23/value
cat /sys/class/gpio/gpio23/value
sleep 1
echo 0 > /sys/class/gpio/gpio23/value
cat /sys/class/gpio/gpio23/value
sleep 1
done
@krishnan793
krishnan793 / Dec2Hex.c
Last active January 11, 2020 03:50
Decimal to Hex Conversion using recursion.
#include<stdio.h>
void Dec2Hex(int no){
int hex=0;
if(!no)
return;
else {
hex=no%16;
Dec2Hex(no/16);
}
@krishnan793
krishnan793 / Power_Law_Transformation.m
Created December 18, 2014 16:38
Power law transformation of an image.
%% Power-Law Transformation
% Equation s=cr^a
A=imread('401566.jpg');
A=rgb2gray(A);
c=1;
a=2.2;
imshow(uint8(c*(double(A).^a)));
@krishnan793
krishnan793 / log_transform.m
Created December 18, 2014 16:36
Log transformation of an image.
%% Log Transform
% Equation s=c*log(1+r)
A=imread('401566.jpg');
A=rgb2gray(A);
imshow(log(double(A)+1));
@krishnan793
krishnan793 / linear_transform.m
Last active August 29, 2015 14:11
Linear Transformation or Negative of an Image
A=imread('401566.jpg'); %Change 401566.jpg with your image file
A=rgb2gray(A);
imshow(255-A); %(L-1)-r;L=256(8 bit gray scale)