Bionic Arm for my physically disabled teacher

Hello, I am making a bionic arm for my physically disabled teacher. I need help for the coding part. I will control the servo with an emg sensor, but I will transfer data wirelessly with RF24L01.
Can you post a sample code for the transmitter?
I want a code for the elbow part in inmoov's 3d bicep model
keep your support

there are many tutorials for the RF24L01. You should look at those

I searched but I couldn't find wireless servo control with emg sensor, my English is not good, I live in Turkey :confused:

HINT: Get it working without the wireless, then add the wireless.

of course not... learn how to send data and apply that to your project

ı already did but continually void value not ignored as it ought to be Gives a fault

continually void value not ignored as it ought to be Gives a fault

not sure what you are saying

have a look at this tutorial for example

Then it is not working is it?

Hi, @emohizli
Welcome to the forum.

Can you please post your two codes so we can see at what stage you are at.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

hello tom now i am writing the transmitter codes, i installed 5 flex sensors and 1 mpu6050 system, on top of that i am trying to add 1 vein sensor code, i am leaving the codes up to where i come from.
TRANSM_TTER_0.ino (3.3 KB)
muscle sensor.ino (1.4 KB)

no problem with the codes of the receiver, my problem is the codes of the transmitter

Hello @emohizli
This approach is similar to your code the differences are that you have everything related to the mpu6050 at your fingertips.
Acceleration
gyro
Yaw
Pitch
Roll
This also incorporates calibration of the gyro and accelerometers
How it works
Every 10 MS the Embedded Digital Motion Processing has a packet ready for you to use
once the packet is ready in the FIFO (First in First out) buffer we capture it and then run the function you specify here:

mpu.on_FIFO(Transmit); // Set callback function that is triggered when FIFO Data is

the Transmit function must have this structure to receive the data:

void Transmit(int16_t *gyro, int16_t *accel, int32_t *quat, uint32_t *timestamp) {
// your code here
}

So every time data is ready this function is ran and you get to do what you want with the data

  float ypr[3] = { 0, 0, 0 };
  float xyz[3] = { 0, 0, 0 };
  mpu.GetQuaternion(&q, quat);
  mpu.GetGravity(&gravity, &q);
  mpu.GetYawPitchRoll(ypr, &q, &gravity);
  mpu.ConvertToDegrees(ypr, XYZ);

//ypr is in radians
//XYZ is in degrees

I hope this gives you a few more options
My Simple_MPU library is found here: https://github.com/ZHomeSlice/Simple_MPU6050

ZhomeSlice

Example of Using my library with your code.

//Verici kodları (El) by TroubleCoder
#include <Servo.h>
#include <SPI.h>                      //Modem ile iletişim sağlamamıza yadımcı olan kütüphane
#include "RF24.h"                     //Radyo modemi kontrol etmemize yardımcı olan kütüphane
#include "Wire.h"                     //TWI cihazlarıyla iletişim kurmamızı sağlayan kütüphane
#include "I2Cdev.h"                   //Mpu6050 modülünün arduino ile haberleşmesini sağlayan kütüphane

#include "Simple_MPU6050.h"
#define MPU6050_DEFAULT_ADDRESS     0x68 // address pin low (GND), default for InvenSense evaluation board

Simple_MPU6050 mpu;

int16_t ivmeX, ivmeY, ivmeZ;          //İvme için x, y ,z değişkenlerini atadık
int16_t gyroX, gyroY, gyroZ;          //Gyro için x, y ,z değişkenlerini atadık

int derece[1]; //Yollanacak paketlerin toplam sayısı(MPU6050)

int msg[6]; //Yollanacak paketlerin toplam sayısı (FLEX)

//Esneklik sensörlerinin giriş pinlerini tanımlıyoruz

int flex_5 = A6;
int flex_4 = A3;
int flex_3 = A2;
int flex_2 = A1;
int flex_1 = A0;

//Esneklik sensör değerleri için değişkenleri tanımlıyoruz.

int flex_5_val;
int flex_4_val;
int flex_3_val;
int flex_2_val;
int flex_1_val;

RF24 radio(9, 10);                    //9 ve 10, CE ve CSN sinyallerinin bağlı olduğu dijital pin numaraları olarak atadık.

const uint64_t pipe = 0xE8E8F0F0E1LL; //Arduino'dan veri alacak olan modemin adresi.

void Transmit(int16_t *gyro, int16_t *accel, int32_t *quat, uint32_t *timestamp) {
  Quaternion q;
  VectorFloat gravity;
  float ypr[3] = { 0, 0, 0 };
  float xyz[3] = { 0, 0, 0 };
  mpu.GetQuaternion(&q, quat);
  mpu.GetGravity(&gravity, &q);
  mpu.GetYawPitchRoll(ypr, &q, &gravity);
  mpu.ConvertToDegrees(ypr, xyz);

  flex_5_val = analogRead(flex_5);
  flex_5_val = map(flex_5_val, 630, 730, 80, 20);              //flex 5 değer atandı

  flex_4_val = analogRead(flex_4);
  flex_4_val = map(flex_4_val, 520, 710, 70, 175);            //flex 4 değer atandı

  flex_3_val = analogRead(flex_3);
  flex_3_val = map(flex_3_val, 510, 680, 140, 10);            //flex 3 değer atandı

  flex_2_val = analogRead(flex_2);
  flex_2_val = map(flex_2_val, 580, 715, 90, 175);            //flex 2 değer atandı

  flex_1_val = analogRead(flex_1);
  flex_1_val = map(flex_1_val, 550, 700, 90, 175);            //flex 1 değer atandı

  msg[0] = flex_5_val;     //flex sensör 5 değeri msg 0 komutunu çalıştıracak
  msg[1] = flex_4_val;     //flex sensör 4 değeri msg 1 komutunu çalıştıracak
  msg[2] = flex_3_val;     //flex sensör 3 değeri msg 2 komutunu çalıştıracak
  msg[3] = flex_2_val;     //flex sensör 2 değeri msg 3 komutunu çalıştıracak
  msg[4] = flex_1_val;     //flex sensör 1 değeri msg 4 komutunu çalıştıracak

  radio.write(msg, sizeof(msg));  //RF24 ile msg komutlarını gönder

  ivmeX = accel[0];
  ivmeY = accel[1];
  ivmeZ = accel[2];

  gyroX = gyro[0];
  gyroY = gyro[1];
  gyroZ = gyro[2];
  //  mpu.getMotion6(&ivmeX, &ivmeY, &ivmeZ, &gyroX, &gyroY, &gyroZ);  // hem gyro hem ivme değerlerinin hepsini oku
  derece[0] = map(ivmeX, 0, 17000, 0, 179);                         //ivmeX okumayı başlat
  radio.write(derece, 1);                                         //RF24 ile sinyal yolla


}

void setup() {
  uint8_t val;
  Wire.begin();
  Wire.setClock(400000);           // 400kHz I2C clock.
  Wire.setWireTimeout(3000, true); //timeout value in uSec

  Serial.begin(9600);                 //Seri haberleşmeyi başlat
  radio.begin();                      //Radio haberleşmeyi başlat.
  radio.openWritingPipe(pipe);        //Programın veri göndereceği alıcının adresini ayarla.

  mpu.Set_DMP_Output_Rate_Hz(100);         // Set the DMP output rate from 200Hz to 5 Minutes.
  mpu.SetAddress(MPU6050_DEFAULT_ADDRESS); //Sets the address of the MPU.
  mpu.CalibrateMPU();                      // Calibrates the MPU.
  mpu.load_DMP_Image();                    // Loads the DMP image into the MPU and finish configuration.
  mpu.on_FIFO(Transmit);               // Set callback function that is triggered when FIFO Data is retrieved
}

void loop() {
  static unsigned long FIFO_DelayTimer;
  if ((millis() - FIFO_DelayTimer) >= (99)) { // 99ms insted of 100ms to start polling the MPU 1ms prior to data arriving.
    if ( mpu.dmp_read_fifo(false)) FIFO_DelayTimer = millis() ; // false = no interrupt pin attachment required and When data arrives in the FIFO Buffer reset the timer
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.