OpenRoberta / openroberta-lab

The programming environment »Open Roberta Lab« by Fraunhofer IAIS enables children and adolescents to program robots. A variety of different programming blocks are provided to program motors and sensors of the robot. Open Roberta Lab uses an approach of graphical programming so that beginners can seamlessly start coding. As a cloud-based application, the platform can be used without prior installation of specific software but runs in any popular browser, independent of operating system and device.
Apache License 2.0
124 stars 121 forks source link

RGB LED does not show red color, when color is set by a variable #1664

Closed el-voss closed 3 months ago

el-voss commented 4 months ago

Describe the bug I have a RGB-LED wired to a Arduino Uno with the standard configuration of the ORL (red: pin 5, green: pin 6, blue: pin 3). When I set the RGB LED to shine red and I put the colorblock directly into the command, the RGB LED will shine red. But if I use a variable instead, the RGB LED will do nothing at all. The screenshots below suggest, that there is a problem with the RCHANNEL-command, which is used to get the red part of a RGB()-instance.

grafik Figure 1: Codeblocks, that work


#include <Arduino.h>

#include <NEPODefs.h>

int _led_red_R = 5;
int _led_green_R = 6;
int _led_blue_R = 3;
int _v_colour_temp;
void setup()
{
    pinMode(_led_red_R, OUTPUT);
    pinMode(_led_green_R, OUTPUT);
    pinMode(_led_blue_R, OUTPUT);
}

void loop()
{
    analogWrite(_led_red_R, 204);
    analogWrite(_led_green_R, 0);
    analogWrite(_led_blue_R, 0);

}

Figure 2: The corresponding code of Figure 1 shows that the analogWrite-commands get numbers

grafik Figure 3: Codeblocks, that do not work

#include <Arduino.h>

#include <NEPODefs.h>

unsigned int ___f;
int _led_red_R = 5;
int _led_green_R = 6;
int _led_blue_R = 3;
int _v_colour_temp;
void setup()
{
    pinMode(_led_red_R, OUTPUT);
    pinMode(_led_green_R, OUTPUT);
    pinMode(_led_blue_R, OUTPUT);
    ___f = RGB(0xff, 0x00, 0x00);
}

void loop()
{
    analogWrite(_led_red_R, RCHANNEL(___f));
    analogWrite(_led_green_R, GCHANNEL(___f));
    analogWrite(_led_blue_R, BCHANNEL(___f));

}

Figure 4: The corresponding code of Figure 3 shows that the analogWrite-commands get CHANNEL-commands

To Reproduce Steps to reproduce the behavior:

  1. Produce the programs above and load them on an Arduino Uno, which is wired to a RGB-LED.

Expected behavior

Device information Tried with Firefox on Windows 10 and Firefox on Tuxedo OS (derivative of Ubuntu).

bjost2s commented 3 months ago

tested, well done!