diff --git a/package.json b/package.json index 24cc8ca..0df2d11 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "dist", "media" ], - "version": "3.3.2", + "version": "3.3.3", "description": "Leaphy custom Blockly blocks and arduino code generator", "name": "@leaphy-robotics/leaphy-blocks" } diff --git a/src/generators/arduino/leaphy_original.ts b/src/generators/arduino/leaphy_original.ts index 6b3c77f..c530c97 100644 --- a/src/generators/arduino/leaphy_original.ts +++ b/src/generators/arduino/leaphy_original.ts @@ -40,21 +40,23 @@ function getCodeGenerators(arduino: Arduino) { let speed = arduino.valueToCode(block, "MOTOR_SPEED", arduino.ORDER_ATOMIC) || "100"; - // Map the speed to a range of 150 - 255 to compensate for low PWM signal voltage - if (parseInt(speed) > 0) { - speed = `map(${speed}, 0, 255, 150, 255)`; - } + arduino.addInclude( "include_leaphy_original", '#include "Leaphyoriginal1.h"', ); // Set different motor pins for nano robots - if (arduino.robotType.includes("nano")) + if (arduino.robotType.includes("nano")) { + if (parseInt(speed) > 0) { + // Map the speed to a range of 150 - 255 to compensate for low PWM signal voltage + speed = `map(${speed}, 0, 255, 150, 255)`; + } arduino.addSetup( "set_motor_pins", "setMotorPins(3, 2, 11, 4);", true, ); + } return `setMotor(${dropdown_Type}, ${speed});\n`; };