Raspberry Pi GPIO
- Posted by Jerome Jan 06, 2013
- 1454 views
Here is a snippet of Eu code that controls the brightness of a led (light-emitting diode) connected to the Raspberry Pi! It is based on the Wiring Pi library which is written in C.
without warning include std/os.e -- Setup GPIO pins integer pinMode = 0 if ( setupGPIO(pinMode) ) < 0 then abort(1) end if -- Set pin 1 to PWM constant PWM = 2 pinMode(1, PWM) -- Set the initial brightness of the LED integer bright = 0, inc = 10 pwmWrite(1,bright) -- While loop that changes LED brightness while( get_key() < 0 ) do pwmWrite(1, bright) bright += inc if bright >= 1020 or bright <= 0 then inc = -inc end if sleep(0.01) end while -- Turn LED off pwmWrite(1,0)
Would something along these lines be useful to add support for?
Thanks,
Ira