Blockly.JavaScript['sendtoarduino'] = function(block) {
  var value_message = Blockly.JavaScript.valueToCode(block, 'MESSAGE', Blockly.JavaScript.ORDER_ATOMIC);
  // TODO: Assemble JavaScript into code variable.
  var code = 'sendString("'+ value_message + ';"); \n';
  return code;
};

Blockly.JavaScript['turn_led'] = function(block) {
  var dropdown_val = block.getFieldValue('val');
  // TODO: Assemble JavaScript into code variable.
  var code = 'sendString("LED_'+ dropdown_val + ';");\n';
  return code;
};

Blockly.JavaScript['arduino_wait'] = function(block) {
  var value_time = Blockly.JavaScript.valueToCode(block, 'time', Blockly.JavaScript.ORDER_ATOMIC);
  let time_ms = Math.round(value_time*1000);
  var code = 'sendString("DELAY_'+time_ms+';");\n waitForUnlockFromArduino();\n';
  return code;
};
