Skip to content

Commit

Permalink
fix: use pin 9,10,11 in rgb block for all nano robots
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoesbergen committed Oct 19, 2024
1 parent 8e2c8e2 commit d6b5da6
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/generators/arduino/leaphy_original.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ function getCodeGenerators(arduino: Arduino) {
"0";
const blue =
arduino.valueToCode(block, "LED_BLUE", arduino.ORDER_ATOMIC) || "0";
arduino.addInclude(
"include_leaphy_original",
'#include "Leaphyoriginal1.h"',
);
return `setLed(${red}, ${green}, ${blue});\n`;

let pin_red, pin_blue, pin_green;
if (arduino.robotType.includes("nano")) {
pin_red = 11;
pin_green = 10;
pin_blue = 9;
arduino.addSetup(
"setup_nano_rgb",
"pinMode(8, OUTPUT);\n digitalWrite(8, LOW);",
false,
);
} else {
pin_red = 3;
pin_green = 5;
pin_blue = 6;
}
// Ground is connected to pin 8 on the nano, so it needs to be pulled LOW
const code =
`analogWrite(${pin_red}, ${red});\n` +
`analogWrite(${pin_green}, ${green});\n` +
`analogWrite(${pin_blue}, ${blue});\n`;

return code;
};

arduino.forBlock["leaphy_original_set_motor"] = function (block) {
Expand Down

0 comments on commit d6b5da6

Please sign in to comment.