Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Arduino: RGB Led with PMW

$
0
0

@TheUnlimitedKoala wrote:

Hello,

I really just started to learn C++ in Openframeworks and can't figure out how to program a RGB led on arduino in Openframeworks. I want to make a smooth transitions with the light of the led so that's why i'm working with Pmw but so far I can't even turn on the led anymore.
I'm using pin 9,10 and 11 on the arduino Uno and have Firmate uploaded to my arduino.

Can please someone see what I'm doing wrong?

#include "ofApp.h"
#define PIN_RED 11
#define PIN_GREEN 10
#define PIN_BLUE 9

void ofApp::setup(){
    ofAddListener(arduino.EInitialized, this, &ofApp::setupArduino);
    arduino.connect("COM3");
    arduino.sendFirmwareVersionRequest();
}

void ofApp::update() {
    arduino.update();
    arduino.sendDigital(PIN_RED, 255);
    arduino.sendDigital(PIN_GREEN, 255);
    arduino.sendDigital(PIN_BLUE, 0);
}

void ofApp::setupArduino(const int& version) {
    ofRemoveListener(arduino.EInitialized, this, &ofApp::setupArduino);

    arduino.sendDigitalPinMode(PIN_RED, ARD_PWM);
    arduino.sendDigitalPinMode(PIN_GREEN, ARD_PWM);
    arduino.sendDigitalPinMode(PIN_BLUE, ARD_PWM);

    ofAddListener(arduino.EDigitalPinChanged, this, &ofApp::digitalPinChanged);
    ofAddListener(arduino.EAnalogPinChanged, this, &ofApp::analogPinChanged);

}

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles