Quantcast
Channel: arm - openFrameworks
Viewing all articles
Browse latest Browse all 147

Running addressable LED strip and rpi4

$
0
0

Im looking for the GPIO pin address in the code that controls the input for the LED’s, its probaby obvious but could someone point it out. I want to connect my strip to the pi but have no idea which pin is being used.

I would like to control an array of LED’s using this addon ofxGPIO by @kashim .

#include "ofMain.h"
#include "ofAppNoWindow.h"
#include "ofxGPIO.h"

class ofApp : public ofBaseApp
{
        public:
		LED apa;
		vector<ofColor> colors;
		int numLed;
		int brightness;
    
        void create_palett()
        {
            for(int i = 0; i < numLed; i++) {
                colors.push_back(ofColor(
                                         (int)ofRandom(0,255),
                                         (int)ofRandom(0,255),
                                         (int)ofRandom(0,255)
                                         ));
            }
        }

        void gen_palett()
        {
            for(int i = 0; i < numLed; i++) {
                colors[i] = ofColor(
                              (int)ofRandom(0,255),
                              (int)ofRandom(0,255),
                              (int)ofRandom(0,255)
                              );
            }
        }

		void setup()
		{
			brightness = 5;
			numLed     = 95;
			create_palett();
			apa.setupAPA102();
		}

		void update(){
			gen_palett();
			apa.setAPA102(numLed,colors,brightness);
			usleep(100000);
            //cycling from blackout up to max brightness
            if(brightness<31) brightness++;
            else brightness=0;
		}
		
		void exit(){
			ofLog()<<"Exit";
			apa.clearAPA102(numLed+5);
			ofExit(0);
		}

		
};

int main( ){
        ofAppNoWindow w;
	ofSetupOpenGL(&w,0,0, OF_WINDOW);
	ofRunApp( new ofApp() );
}

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 147

Trending Articles