Arduino Library With Robo Wunderkind

Tell us the story of your project: 

Hello Makers!

Robo Wunderkind has now developed an Arduino library for all the makers out there. It brings the two worlds of Robo Wunderkind and Arduino together. Take a look at this step-by-step instruction and see for yourself how it works! Watch the video to get the visual explanation.

Enjoy :)

How-to: 

Materials Needed:

 - Robo Wunderkind Kit  https://www.amazon.com/Robo-Wunderkind-Robotics-Education-Programmable/d...

 - ESP32 Board  https://www.amazon.com/HiLetgo-ESP-WROOM-32-Development-Microcontroller-...

 - 1602 LCD Display https://www.amazon.com/LGDehome-Interface-Adapter-Backlight-MEGA2560/dp/...

 - A potentiometer  https://www.amazon.com/Uxcell-a15011600ux0235-Linear-Rotary-Potentiomete...

 - A button  https://www.amazon.com/Cylewet-6%C3%976%C3%979mm-Tactile-Arduino-CYT1052...

 - A 10k Resistor https://www.amazon.com/AUSTOR-Resistors-Assortment-Resistor-Experiments/...

 Wiring (The image is attached):

 1602 LCD SDA to ESP32 Pin 23

 1602 LCD SCL to ESP32 Pin 22

 One side of Button to Pin 5, with the 10K resistor from Pin 5 to 3V3

 Other side of Button to Ground

 Pin 1 of Potentiometer to 3V3

 Pin 2 of Potentiometer to Pin 32

 Pin 3 of Potentiometer to Ground

 

 Libraries needed:

 - Robo Arduino Library  https://github.com/JonRobo/Robo_Arduino_BLE_ESP32

- LiquidCrystal-I2C  https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library

Board Package needed:

- ESP32  https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-id...

 

Now let's move on to code: 

#include <LiquidCrystal_I2C.h>

#include <math.h>  

 

#include "Robo_BLE.h"

 

#define Robo_Name  "Robo Arduino" // change to match the Robo name you wish to connect to

#define Button 5

#define Knob 32

 

// set the LCD number of columns and rows

int lcdColumns = 16;

int lcdRows = 2;

float knob_value = 0;

bool led_state = 0;

bool button_state = 0;

int light = 100;

String text1 = " Thank-you KickStarter!    ";

String text2 = "Thank-you KickStarter!    ";

 

// Create Robo_BLE Instance

Robo_BLE RW = Robo_BLE();

// Create LCD Instance

LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);

 

void setup() {

  Serial.begin(115200);

  pinMode(Button, INPUT);

 

  lcd.init();

  lcd.backlight();

  lcd.setCursor(0, 0);

  lcd.print("Initialized");

  delay(1000);

  

  if(RW.init(Robo_Name)){  // Initialize Robo

    Serial.println("Robo Connection Success!");

    Serial.println(RW.get_firmware_version());

    lcd.backlight();

    lcd.setCursor(0, 0);

    lcd.print("Robo Connected!");

    delay(1500);

    lcd.clear();

    // Stagger the same message shifted 1 character across the two displays so it looks like they're working together

    RW.scroll_text(text2, 1, 1, 25, 9 , 23);

    RW.scroll_text(text1, 2, 1, 25, 9 , 23);

    RW.RGB_OFF(1);

  }

  else { //BLE Connection failed please check to make sure the Robo Name is correct

    Serial.println("Robo Connection Failure!");

    lcd.backlight();

    lcd.setCursor(0, 0);

    lcd.print("Connect Fail");

    delay(1500);

    lcd.clear();

  }

}

 

// Grab data from the sensors

void get_states(){

  int green = 0;

  if(digitalRead(Button) == 0 && button_state == 1){

    led_state = !led_state;

    if(led_state == 1) RW.RGB(0,255,0,1);

    if(led_state == 0) RW.RGB_OFF(1);

  }

  button_state = digitalRead(Button);

  knob_value = ((float)analogRead(Knob)/4095.0)*100;

  light = RW.get_light_state(1);

  Serial.println("Button Effect State = " + String(button_state));

  Serial.println("LED State = " + String(led_state));

  Serial.println("Knob Level = " + String(knob_value));

 

  if(led_state == 1){

    green = 255*(float(knob_value)/100.0);

    Serial.println("Green = " + String(green));

    RW.RGB(0,green,0,1); 

  }

}

// makes sure that each time we write it fills the entire line so we get a seemless transition in values

void lcd_write_fill(int num, int room){

  uint8_t chars = log10(num)+1;

  String filler = " ";

  for(int i = 0; i < (room-chars); i++){

    filler += " ";

  }

  lcd.print(String(num)+filler);

}

 

void loop() {

  

  get_states(); // aquire data

 

  // Display LED Brightness on first row

  lcd.setCursor(0, 0);

  lcd.print("LED Level: ");

  lcd.setCursor(11, 0);

  if(led_state) lcd_write_fill((int)knob_value, 6);

  else lcd.print("OFF");

  

  // Display Light data on second row

  lcd.setCursor(0,1);

  lcd.print("Light Val: ");

  lcd.setCursor(11, 1);

  lcd_write_fill(light, 6);

  delay(150);

   

}

 

Difficulty: 
Duration: 
Collaborators: 
varia
Number of Forks: 
0
Choose at least one category.: 
Boards & Kits: 
Name: 
Robo Wunderkind Kit
Quantity: 
1
Team Members: 
Team member name: 
varia
What role did this person play on the project?: 
Project Lead
Public
Sort Order: 
0
Teaser: 
Robo Wunderkind has now developed an Arduino library for all the makers out there. It brings the two worlds of Robo Wunderkind and Arduino together.
Show & Tell video as default: 
Creation Date: 
Monday, October 28, 2019 - 13:32