Table of contents 2 B4R Example Projects
1 Getting started .............................................................................................................................. 6
1.1 Useful links .......................................................................................................................... 6
2 Arduino UNO board ..................................................................................................................... 7
2.1 Power supply ........................................................................................................................ 8
2.2 Pins ....................................................................................................................................... 8
2.2.1 Power pins ........................................................................................................................ 8
2.2.2 Digital Input / Output pins ............................................................................................... 9
2.2.3 Analog input pins ............................................................................................................. 9
2.3 Input modes INPUT / INPUT_PULLUP ............................................................................ 9
2.4 Basic Pin functions ............................................................................................................. 10
2.4.1 Initialize.......................................................................................................................... 10
2.4.2 DigitalRead .................................................................................................................... 11
2.4.3 DigitalWrite.................................................................................................................... 11
2.4.4 AnalogRead .................................................................................................................... 11
2.4.5 AnalogWrite ................................................................................................................... 12
2.5 RunNative inline C ............................................................................................................ 13
3 B4R differences versus B4A/B4J/B4i ........................................................................................ 14
3.1 No user interface ................................................................................................................ 14
3.2 Memory .............................................................................................................................. 14
3.3 Stack Buffer ....................................................................................................................... 15
3.4 ByteConverter .................................................................................................................... 15
3.5 Concatenation ..................................................................................................................... 16
3.6 String methods ................................................................................................................... 17
3.7 Encoding ............................................................................................................................ 18
3.8 Variables ............................................................................................................................ 18
3.9 New Keywords ................................................................................................................... 19
3.9.1 AddLooper ..................................................................................................................... 19
3.9.2 AvailableRAM ............................................................................................................... 19
3.9.3 CallSubPlus .................................................................................................................... 19
3.9.4 Delay .............................................................................................................................. 20
3.9.5 DelayMicroseconds ........................................................................................................ 20
3.9.6 JoinBytes ........................................................................................................................ 20
3.9.7 JoinStrings ...................................................................................................................... 20
3.9.8 MapRange ...................................................................................................................... 21
3.9.9 Micros ............................................................................................................................ 21
3.9.10 Millis .......................................................................................................................... 21
3.9.11 StackBufferUsage ...................................................................................................... 21
3.10 Variable Types ................................................................................................................... 22
3.10.1 Array variables ........................................................................................................... 23
3.10.2 Array of objects .......................................................................................................... 24
3.10.3 Type variables ............................................................................................................ 25
3.11 Casting ............................................................................................................................... 26
4 First example programs .............................................................................................................. 27
4.1 Button.b4r .......................................................................................................................... 28
4.1.1 Sketch ............................................................................................................................. 28
4.1.2 Code ............................................................................................................................... 29
4.2 LedGreen.b4r ..................................................................................................................... 30
4.2.1 Sketch ............................................................................................................................. 30
4.2.2 Code ............................................................................................................................... 31
4.3 LedGreenNoSwitchBounce.b4r ......................................................................................... 32
4.3.1 Sketch ............................................................................................................................. 33
4.3.2 Code ............................................................................................................................... 34
5 More advanced programs Arduino Uno ................................................................................... 35