I'm still waiting for my Pi Camera, and an model A to install a birdbox camera project. In the meantime, I'm mpreparing the other bits. Today, my PiEye case came in the post - this has a built in white LED. What I'd like to do is turn on the white LED during daytime to help the visibility / colour rendition of the picture, and turn it off at night. I'll add an IR LED to illuminate during the nighttime too.
Install wifi and get setup for headless.
Enable ssh.
Install Wiringpi from https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/
sudo apt-get install git-core (already latest version)
pi@camerapi ~/light $ cd wiringPi/ pi@camerapi ~/light/wiringPi $ git pull origin
./build - This builds and installs the wiringPi library. All OK.
Now, gcc -o blink ./blink.c -lwiringPi - this builds OK.
/* * blink.c: * blinks the first LED * Gordon Henderson, projects@drogon.net */ #include <stdio.h> #include <wiringPi.h> int main (void) { printf ("Raspberry Pi blink\n") ; if (wiringPiSetup () == -1) return 1 ; pinMode (0, OUTPUT) ; // aka BCM_GPIO pin 17 for (;;) { digitalWrite (0, 1) ; // On delay (500) ; // mS digitalWrite (0, 0) ; // Off delay (500) ; } return 0 ; }
My Pi Eye LED is connected between pins 1 and pin 11 (gnd and gpio17 on the header on the PI.
Running sudo ./blink blinks the LED - great. This confirms I can make this work from software.
So - even I can hack this to make an on and off routine.
/* * on.c: * turns on LED on pin 11 (gpio 17) */ #include <stdio.h> #include <wiringPi.h> int main (void) { printf ("Pi Eye LED on\n") ; if (wiringPiSetup () == -1) return 1 ; pinMode (0, OUTPUT) ; // aka BCM_GPIO pin 17 digitalWrite (0, 1) ; // On return 0 ; }
And Off.
/*
* off.c:
* turns on LED off pin 11 (gpio 17)
*/
#include <stdio.h>
#include <wiringPi.h>
int main (void)
{
printf ("Pi Eye LED off\n") ;
if (wiringPiSetup () == -1)
return 1 ;
pinMode (0, OUTPUT) ; // aka BCM_GPIO pin 17
digitalWrite (0, 0) ; // On
return 0 ;
}
Cool - that was easy!
No comments:
Post a Comment
Note: only a member of this blog may post a comment.