B4R Question Nano script compile fails (DigitalWrite)


Well-Known Member
Licensed User
I recently bought an "arduino" Nano Every. There was some things that were puzzling and it turns out it is a CLone made by Thinary (Thinary Nano Every).

Loaded the specification/driver (source: Github) in the Arduino IDE and did some tests - aiming in the end to use this board as a learning exercise for B4R.

I found that the arduino sketch would load onto the board (Arduino IDE - indicating the serial comm works), however, nothing shows up in the Serial Monitor.

After some time banging at that, I just moved to B4R IDE. Am able to select the board and the COM port etc (or it was auto-recognised).

Using a test sketch from Klaus's booklet (as below) I then encountered a different problem that I can't explain.

The code is this : (and pretty simple with only Core library required apparently) :

Test sketch (B4R booklet):
 #Region Project Attributes
        #AutoFlushLogs: True
        #CheckArrayBounds: True
        #StackBufferSize: 300
    #End Region
    'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src
    Sub Process_Globals
        Public Serial1 As Serial
        Private pin13 As Pin
    End Sub
    Private Sub AppStart
        pin13.Initialize(13, pin13.MODE_OUTPUT)
    End Sub
    Private Sub LedOn (tag As Byte)
        CallSubPlus("LedOff", 1000, 0)
    End Sub
    Private Sub LedOff(tag As Byte)
        CallSubPlus("LedOn", 1000, 0)
    End Sub

On the debug side I get this : The following is just the bit that seems most relevant to the query (the full debug capture is in the attachment).

"K:\\B4R-PR~1\\xxxxxxx\\Objects\\bin\\sketch\\Scheduler.cpp" -o "K:\\B4R-PR~1\\xxxxxxx\\Objects\\bin\\sketch\\Scheduler.cpp.o"
K:\B4R-PR~1\xxxxxxx\Objects\src\B4RArduino.cpp: In member function 'void B4R::pin::DigitalWrite(bool)':
B4RArduino.cpp:48:32: error: cannot convert 'bool' to 'PinStatus' for argument '2' to 'void digitalWrite(pin_size_t, PinStatus)'
digitalWrite(PinNumber, Value);
Using library SoftwareSerial at version 1.0 in folder: C:\Users\RabbitBush\AppData\Local\Arduino15\packages\thinary\hardware\avr\1.0.0\libraries\SoftwareSerial
exit status 1

So, the puzzling part is
B4RArduino.cpp:48:32: error: cannot convert 'bool' to 'PinStatus' for argument '2' to 'void digitalWrite(pin_size_t, PinStatus)'
digitalWrite(PinNumber, Value);

I thought I would comment out the pin13.DigitalWrite lines in the code and the Debug still showed the same error.

I also thought, so it needs two parameters in DigitalWrite and go this in the log when I added pin13 as a first parameter (though its the wrong type for that first parameter) :
Main - 19: Cannot cast type: {Type=Pin,Rank=0, RemoteObject=True} to: {Type=Boolean,Rank=0, RemoteObject=True}
Main - 23: Cannot cast type: {Type=Pin,Rank=0, RemoteObject=True} to: {Type=Boolean,Rank=0, RemoteObject=True}

Couldn't spot anything in the full debug log that showed some failure in the TRACE/DEBUG.

Pretty certain I have the latest version of B4R and its libraries.

I could have missed adding a library but when I added several they just all showed up as Unused in the log - hence it seemed that this was an unlikely error on my part.

At this point the issue can't be unrelated to the hardware (ie the clone device) - the sketch has not compiled and tried to upload (yet).

Any assistance welcomed : thanks.


  • trace-log.txt
    71.2 KB · Views: 39


Well-Known Member
Licensed User
It isn't related to your code.

Which version of Arduino IDE have you installed?
Noted : not code related.

Arduino IDE is 1.8.15 - updated about a 10 days ago.
Upvote 0


Well-Known Member
Licensed User
Yikes- thanks @Erel - I would never have found that - proving my notion about figuring out the right search questions. Interesting is that the code in #1 never used boolean/bool. It seems to just react to line 48 in B4RArduino.cpp (which is referencing AnalogueWrite, the next few lines refer to DigitalWrite) when it compiles. So it's all happening before the code execution, as I am sure you understand.

I will figure out the board configuration screenshot Later today. Though that link suggests it's all inside the arduino's cores.

Thanks again, will be in touch.......
Upvote 0


Well-Known Member
Licensed User
post a screenshot of the board configuration dialog?
Sorry Erel - (having a blonde moment) which screenshot? can't see any that look like that description.
Upvote 0


B4X founder
Staff member
Licensed User
This one:
Upvote 0


Well-Known Member
Licensed User
Oi truly - it was actually that obvious - who knows what happened that day . . . .

Here it is : I see differences between your capture and this one : the B4R I have installed is 3.71.

Upvote 0


Well-Known Member
Licensed User
Have you tried to select Arduino Nano?
Yes, In the Arduino IDE it just hung-up when loading BLINK.
Arduino NANO does not work - found the wrong chip signature (see below board differences)
Arduino NANO Every - same thing.

In B4R -
SELECTING Arduino NANO Every -
Sketch uses 4043 bytes (8%) of program storage space. Maximum is 49152 bytes.
Global variables use 228 bytes (3%) of dynamic memory, leaving 5916 bytes for local variables. Maximum is 6144 bytes.
An error occurred while uploading the sketch
DEBUG StatusLogger Stopping LoggerContext[name=1e6f5c3, org.apache.logging.log4j.core.LoggerContext@168f0dc]
No information in the rest of the log about what that error is - but probably relates to the text below. Nothing was written to the board.

SELECTING Arduino NANO Every - the error this posting is about.

Is it a completely different board?
Differences between the Arduino Nano Every and this Thinary Nano Every
Arduino uses a ATMEGA4809 chip and the Thinary uses ATMEGA4808.​
Next difference - the NANO EVERY board has 4 extra pins - both versions. [EDIT - I just looked at the pin-out diagram for the Arduino Nano Every -> it has 30 (15/15) pins. On the Thinary I have it has the 4 extra pins (17/17).)

This says Arduino Nano but that the board I have which is a clone. (how's your russian : )


NANO EVERY has extra memory 48k vs 32k - (basically why I bought the board - vendor did note the 4808/9 chip difference).

I seem to recall - after reading the Arduino Forum thread you sent - that I saw a work around - will have to go back and search again.

I thought to comment out LINE 48 in B4RArduino.cpp and just see what happens - but then, it looks as if Arduino has made some decision that breaks this (whether the decision is logical or not I couldn't say - threads in the fora say that many thing will break if ported to the Every).

Interesting that Andreas Spiess tested this and other boards but did not highlight this issue.
Last edited:
Upvote 0


Well-Known Member
Licensed User
They made incompatible changes in their SDK. You will need to find a different one.
Maybe this one: https://github.com/MCUdude/MegaCoreX
Yes I saw that - i did dig into that information but it seems like it will need some hardware to reprogram the 4808 chip. I was going to revisit tonight -

- but - Not going to spend more time on it now which is a pity since the extra flash space would be useful - even the extra pins. Looks like Arduino might have to address the problem so i will wait and see.

-[EDIT apparently this persists when using Arduino IDE 2.0 beta - released recently. ]

Thanks Very much for your thinking about this and the suggestions - much appreciated. Maybe we both found new things here?

I guess this thread has died - cheers.
Last edited:
Upvote 0