B4R Tutorials

Writing and reading from the EEPROM

The EEPROM is in most cases the only persistent storage available. As a persistent storage we can use it to store data that will not be lost when the board is turned off.

The rEEPROM library...
 

Timers, Loopers and CallSubPlus

Arduino C example #1:
B4X:
void setup() {
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the...
 
Last edited:

[Hint] 10 methods to easily destroy your Arduino

B4R Beginner's Guide

This guide is obsolete ! It is no more updated.
Please use the B4X Booklets.

Here you find the B4R Beginner's Guide in pdf format.

The source code for the example programs is...
 
Last edited:

Reed Switch Monitor Example

B4R & B4J experiment to monitor the state of a Reed switch connected to an ESP8266 - a NodeMCU is used. If the Reed switch state changes (triggered by a magnetic contact), data is send to a B4J...
 
Last edited by a moderator:

Blink Example

A simple example that uses a Timer to change the state of pin 13 (this is the pin connected to the built-in led):
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private Timer1 As Timer...
 

ESP8266 + Relay = Let there be light

Relays are electronic switches that allow low power (voltage) devices to control high power circuits.

In this example the ESP8266 board controls a regular 220v light bulb.

*** High power...
 

Attachments

  • B4A_Relay.zip
    7.8 KB · Views: 1,339
Last edited:

TIME to Uint / Unit to TIME Converter

I using this code, Because Board has a problem for records size capacity of epprom.

Sample
B4X:
Log("17:45:36 False >>",DateTime.TimeToUint(17,45,36,False)) '>>> 1065
    Log("1065 // 17:45:36...
 
Last edited:

DATE to Uint / Unit to Date Converter

I using this code, Because Board has a problem for records size capacity of epprom.
B4X:
'For date >> 2015/ 08 / 04 (y/m/d)
Log("Date number:",DateTime.DateToUint(15,8,4)))
'returned >>
'Date...
 
Last edited:

Using PROGMEM to save memory

The smaller Arduinos like the Arduino Uno have 2k of RAM. The subs stack and the global variables use this memory.

If your program includes constant data then you can use PROGMEM to store the...
 

Ultrasonic Ranging module HC-SR04

Testing the HC-SR04 to measuring distances

ultrasonic_sensor_schema.jpg

physics info.png

The accuraccy of the sensor depends greatly on...
 
Last edited by a moderator:

sub for Date Time adding

Hello;
I needed date time functions; And some write codes.
it is first sharing with B4R

use this variables for date &time
Public Time_HH As Int
Public Time_MM As Int
...
 
Last edited:

Intel Arduino 101

ABX00005_featured_grande.jpg


The Arduino 101 is an Arduino board developed by Intel. It is mostly compatible with standard...
 

Attachments

  • boards.zip
    2.5 KB · Views: 642
  • B4R_Serial_Connector_Arduino101.zip
    4.9 KB · Views: 612
Last edited:

Servo motor and Arduino

Thanks to @Erel and the new rservo library (Beta#7), we've access to servo motors.

Servos are a motor type that allows for precise control of angular or linear position, velocity and...
 
Last edited:

Inertial Measurements (MPU 6050) and Magnetometer (HMC5883L)

With big help from Erel here are two examples of connecting two boards by the I2C/TWI (A4 and A5 pins), using the rWire library.
Inertial Measurements (mpu6050) :
B4X:
' MPU 6050 board - Inertial...
 
Last edited:

Stepper motor

Edit: see post #5 for an updated version.

This application is controlling a stepper motor which can be turned by a wanted angle and speed. I use this motor...
 
Last edited:

Memory, Variables and Objects

Memory is a big issue in Arduino.

1. The available RAM is very small compared to other platforms. For example the Uno has 2k of RAM.
2. There is no sophisticated heap management which means that...
 
Last edited:

B4R Change Log (version history)

Last edited:

[Hint] HC-05,06 Power supply

Hello all, I read a few posts asking about the power supply requirements of the Bluetooth module. I thought I can put this hint so people can use the right voltage or power supply.
The HC-x comes...
 

B4R/B4J Experiment - Control Servo Motor connected to Arduino via Browser

This experiment moves a Little Crane arm (used some Lego parts) up and down via browser connected to a B4J websocket server.
When the arm moves, the Red LED is turned on else the Green LED is on...
 

Attachments

  • b4rhowtoservomotorbrowser.zip
    254 KB · Views: 640
Last edited:
Top