Gus nice video tutorial explained how Arduino sketches can be run on the new BrainPad V2
It turned out to be easy to use the LEDs and the Buttons of the BrainPad in Arduino code.
However there were problems to use the I2C oled display in Arduino code (see discussion on the above thread).
To prevent pollution of this video tutorial thread with to many details I suggest to continue the discussion about the display in this separate thread.
@valon_hoti_gmail_com Yes, the I2C pins should be configured with internal pullups, but I don’t consider this to be the reason as I can see no impulses at all on the I2C lines.
@trent1098s I tried with external 4.7 k resistors, did not help.
That jives with the G30 datasheet and recommendations for the CPU. It’ll work for tons of stuff. Should work for this just fine.
Still always good practice to check the datasheet of the slave devices. Like I mentioned above, I’ve run across certain IC’s that need less impedance. That MCP23017 I mentioned recommends 1k. But that value can also change depending on implementation depending on what devices you have chained together.
Not sure what exactly to do when the datasheets conflict. If one master or slave calls for, say, 2.2k but the other calls for 1k, you split the difference? Use the weaker one? Use the stronger one?
Perhaps someone with more knowledge can give some insight.
namespace BrainPadApplication1
{
class Program
{
public void BrainPadSetup()
{
//Start OLED SSD1306
BrainPad.Display.DrawSmallText(0, 0, “Temperature!”);
}
public void BrainPadLoop()
{
//Turn On Bulb
BrainPad.LightBulb.TurnWhite();
BrainPad.Wait.Seconds(1);
//Turn Off Bulb
BrainPad.LightBulb.TurnOff();
BrainPad.Wait.Seconds(1);
//Clear part of early display
//BrainPad.Display.ClearPartOfScreen(0, 18, 20,20);
//Show result of temperature on display
BrainPad.Display.DrawText(0, 18, BrainPad.TemperatureSensor.ReadTemperatureInCelsius().ToString().Substring(0,5).ToString()+" C");
BrainPad.Display.ShowOnScreen();
}
}
}
by TinyCLR OS (0.6.0) it work well
So just need to call in ARDUINO IDE in same way
i’m going to check/search deep for more behind software side how it was doing by TinyCLR
First check on Arduino IDE I2C pins are PB8 and PB9 (D15,D14) for Nucleo 401 on Brainpad was used PB6 and PB7 so i will try to create Brainpad template based on Nucleo Template but to correspodent pins (that ones used for Braibpad).
if we are talking for i2c software i tested pice of code which :
On nucleo work well same code
On arduino work well but
On brainpad do not work (compile is ok) seems need something to trigger before “using I2C” ??
I took parts of the Adafruit_SSD1306 library in a new Arduino sketch and created a new instance of wire with the correct pins and used this instance for the commands.
for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
// send a bunch of data in one xmission
Wire2.beginTransmission(_i2caddr);
//WIRE_WRITE(0x40);
Wire2.write(0x040);
for (uint8_t x=0; x<16; x++) {
//WIRE_WRITE(buffer[i]);
Wire2.write(buffer[i]);
i++;
}
i--;
Wire2.endTransmission();
}
Now we have to search how it can be achieved that the original wire library takes the correct pins.
O.K., the Adafruit_ssd1306_128x64 library now works perfectly on the BrainPad.
The pin definitions in the file variants.h in the folder:
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\2017.8.4\variants\NUCLEO_F401RE
files and instructions step by step you can find HERE
so we can contribute to Arduino STM32 Core for Brainpad board
(but we are not authorized for this because we need to support it so i published just on my gdrive just for internal usage between us on this forum) and just to say Brainpad is excellent tools that could be used with ARDUINO IDE too for learning.
REMARKS:
if we can apply SERIAL _ UPLOAD (without need for DFU as part of ARDUINO IDE) that will be perfect tools for ARDUINO IDE too.
with Arduinos default libraries test
Display - tested OK (Ardafruit SSD1306 libraries for I2C)
Led - tested OK (simple default test)
Bulbs - tested OK (simple default test)
to be tested with Arduinos default libraries
Temperature Sensor
Servo Motors
Buzzer
next step of works to provide all samples for Brainpad for Arduino IDE (similiar to .NET Framework / TinyCLR OS samples just to recreate them for Arduino IDE) if all works with Arduino Default Libraries (and information which libraries to be used)