The default pinmode for digital input of arduino ports seems to be INPUT instead of INPUT_PULLUP.
This leaves the input port in a floating state, requiring to add an pull-up or pull-down resistor to the project. By enabling the available internal pull-up resistor the need for adding resistors to a project can be prevented.
Also tried to change the baseboard_firmware.ino by changing
case DIGITAL:{
pinMode(pin,INPUT);
sendFloat(digitalRead(pin));
}
break;
into
case DIGITAL:{
pinMode(pin,INPUT_PULLUP);
sendFloat(digitalRead(pin));
}
break;
and in the Arduino.s2e
["B", "read digital pin %n","getDigital","9",
{"encode":"{d0}","setup":"pinMode({0},INPUT);\n","inc":"","def":"","work":"digitalRead({0})","loop":""}],
to
["B", "read digital pin %n","getDigital","9",
{"encode":"{d0}","setup":"pinMode({0},INPUT_PULLUP);\n","inc":"","def":"","work":"digitalRead({0})","loop":""}],
When running an application using a digital read with "When . Clicked" using the mBlock firmware, the pull-up resistor is not enabled and the voltage on the input port is still floating. If ran as an Arduino program the pinmode is set to INPUT_PULLUP and reading the input on the pin gives a stable signal.
The default pinmode for digital input of arduino ports seems to be INPUT instead of INPUT_PULLUP. This leaves the input port in a floating state, requiring to add an pull-up or pull-down resistor to the project. By enabling the available internal pull-up resistor the need for adding resistors to a project can be prevented.
Also tried to change the baseboard_firmware.ino by changing
into
and in the Arduino.s2e
to
When running an application using a digital read with "When . Clicked" using the mBlock firmware, the pull-up resistor is not enabled and the voltage on the input port is still floating. If ran as an Arduino program the pinmode is set to INPUT_PULLUP and reading the input on the pin gives a stable signal.
void setup(){ pinMode(5,INPUT_PULLUP); digitalWrite(5,1); }