Duvam
Published © CC BY-SA

Street Robot Entertainer Partner

Hi, I like street theater a lot, and I m doing a robot that could help me playing on the street. I'm on the way any help would be great

AdvancedWork in progress801

Things used in this project

Hardware components

Arduino Mega
×4
LoRa Arduino Shield
Makestro LoRa Arduino Shield
×2
Arduino Due
Arduino Due
×1
Raspberry Pi 4 Model B
Raspberry Pi 4 Model B
×1
Raspberry Pi Pico
Raspberry Pi Pico
×2
Cytron Technologies 60Amp 7V-45V SmartDrive DC Motor Driver
×1
the t.mix MicroMix 2 USB
×1
shure hf system
×1
amplificateur alpine pdx m12
×1
servo DC12V 24V 380kg.cm TZT
×1
e-cycle battery 36V
×1
8x8 rgb led matrix
×8
WS2812B Digital RGB LED Flexi-Strip 144 LED - 1 Meter
Seeed Studio WS2812B Digital RGB LED Flexi-Strip 144 LED - 1 Meter
×1
250W 24V motor
×2
Donner Octave Guitar Pedal
×1
battery samsung usb 10000mah
×1

Story

Read more

Code

remote control

Arduino
remote control code
#include <SoftwareSerial.h>

//radio transmission
SoftwareSerial hc12(0, 1); //RX, TX

// leds
int led1State = 0;
int led1 = 10;
int led2 = 11;
int led3 = 12;

// joystick
//const int SW_pin = 2; // digital pin connected to switch output
//const int X_pin = 3; // analog pin connected to X output
//const int Y_pin = 4; // analog pin connected to Y output

String ledMod = "000";

/* button config */
int buttonValue() {
  int analogInput [3] = { A0, A1, A2 };
  int value = 0;

  for ( int i = 0 ; i < 3 ; ++i ) {
    if (analogInput[i] > 0) {
      value = getAnalogValue(analogInput[i]);
      //printDebug(value, "analogInput");

      if (value != 0) {

        if (analogInput[i] == 14) {
          if (value  == 1) {
            value = 111;
          } else if (value  == 2) {
            value = 222;
          } else if (value  == 3) {
            value = 333;
          } else {
            value = 1;
          }
        } else if (analogInput[i] == 15) {
          value += 1;
        } else if (analogInput[i] == 16) {
          value += 5;
        }
        break;
      }
    }
  }
  return value;
}


String buttonValueMod() {
  return getModValue() + (String)buttonValue();
}

int getAnalogValue(int analog) {

  int analogValue = analogRead(analog);
  //Serial.println(analogValue);
  int buttonValue = 0 ;
  if (analogValue > 164 & analogValue < 407) {
    buttonValue = 1;
  } else if (analogValue > 407 & analogValue < 707) {
    buttonValue = 2;
  } else if (analogValue > 707 & analogValue < 977) {
    buttonValue = 3;
  } else if (analogValue > 977) {
    buttonValue = 4;
  }
  //Serial.println(analog);
  return buttonValue;
}


/* end button */

void manageLed(int button) {

  if (button == 111) {
    ledOnOff(led1);
  } else if (button == 222) {
    ledOnOff(led2);
  } else if (button == 333) {
    ledOnOff(led3);
  }
}

void ledOnOff(int led) {
  if (digitalRead(led) == LOW) {
    digitalWrite(led, HIGH);
  } else {
    digitalWrite(led, LOW);
  }
  delay(200);
}

int getModValue() {
  String bin = (String)digitalRead(led1) + (String)digitalRead(led2) + (String)digitalRead(led3);
  int hexa = 0;
  if (bin == "000") {
    hexa = 0;
  } else if (bin == "001") {
    hexa = 1;
  } else if (bin == "010") {
    hexa = 2;
  } else if (bin == "011") {
    hexa = 3;
  } else if (bin == "100") {
    hexa = 4;
  } else if (bin == "101") {
    hexa = 5;
  } else if (bin == "110") {
    hexa = 6;
  } else {
    hexa = 7;
  }
  return  hexa;
}

/* Joystick */
int getJystickValue() {
  //Serial.println(digitalRead(SW_pin));
  int x = simplifyAnalogValue(analogRead(3));
  int y = simplifyAnalogValue(analogRead(4));

  if (x > 3 && x < 7 && y > 3 && y < 7) {
    return 0;
  }

  //printDebug(String(x), "x");
  //printDebug(String(y), "y");
  if (x == 0) {
    x = 10;
  } else {
    x = x * 10;
  }
  return  x + y;
}

int simplifyAnalogValue(int v) {
  return ((v * 10) / 1024);
}

/*  End Joystick */

void setup() {

  // radio transmission
  hc12.begin(9600);
  Serial.begin(9600);

  //leds
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

  //joystick
  pinMode(2, INPUT);
  digitalWrite(2, HIGH);

}

void printDebug(String value, String msg) {
  Serial.println(msg);
  Serial.println(value);
}

void loop() {


  int button = buttonValue();
  //printDebug(button, "button");

  if (button != 0) {

    manageLed(button);
    //printDebug(buttonValueMod(), "button pressed");
    String buttonSend = "100" + (String)buttonValueMod();
    printDebug(buttonSend, "button value");

    hc12.println(buttonSend);
  }

  int joystick = getJystickValue();

  if (joystick != 0) {
    String joyStickValue = "200" + (String)joystick;
    printDebug(joyStickValue, "joystick");
    hc12.println(joyStickValue);
  }


  delay(100);

}

Credits

Duvam
1 project • 0 followers

Comments