Dont know how to calculate what i need to have

Hello, i have a complicated system and a couple questions.

This is our system and everyting is fine.

//for motor driver defining pins
#define R_IS 6
#define R_EN 5
#define R_PWM 4
#define L_IS 3
#define L_EN 2
#define L_PWM 1

//for leds defining pins
#define FRONT_LED 7
#define BACK_LED 13

#define S0 8
#define S1 9
#define S2 10
#define S3 11
#define sensorOut 12

int red=0;
int green=0;
int blue=0;

void setup() {
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  pinMode(sensorOut, INPUT);

  digitalWrite(S0, HIGH);
  digitalWrite(S1, LOW);

  Serial.begin(9600);

  //Setting leds
  pinMode(FRONT_LED, OUTPUT);
  pinMode(BACK_LED, OUTPUT);

  //setting driver outputs
  pinMode(R_IS, OUTPUT); pinMode(R_EN, OUTPUT); pinMode(R_PWM, OUTPUT);
  pinMode(L_IS, OUTPUT); pinMode(L_EN, OUTPUT); pinMode(L_PWM, OUTPUT);

  digitalWrite(R_IS, LOW);
  digitalWrite(L_IS, LOW);
  digitalWrite(R_EN, HIGH);
  digitalWrite(L_EN, HIGH);
}

int i = 0;
void loop(){
  //KIRMIZI RENK FİLTRESİ
  digitalWrite(S2, LOW);
  digitalWrite(S3, LOW);
  red = pulseIn(sensorOut, LOW);
  //red = map(red, 30, 245, 0, 100);

  //YEŞİL RENK FİLTRESİ
  digitalWrite(S2, HIGH);
  digitalWrite(S3, HIGH);
  green = pulseIn(sensorOut, LOW);
  //green = map(green, 30, 310, 0, 100);

  //MAVİ RENK FİLTRESİ
  digitalWrite(S2, LOW);
  digitalWrite(S3, HIGH);
  blue = pulseIn(sensorOut, LOW);
  //blue = map(blue, 30, 280, 0, 100);

  i++;
  
  Serial.print("red=");
  Serial.print(red);
  Serial.print(" ");
  Serial.print("Green =");
  Serial.print(green);
  Serial.print(" ");
  Serial.print("blue=");
  Serial.print(blue);
  Serial.println(" ");
  delay(200);
  //motor< stops block

  //sarı bant durdurmak için
  //if (red>=3 && green>=11 && blue>=30 && red<=50 && green<=50 && blue<=50){
  //iodine reaxion ile durdurmak içn
  if (red<=8 && green<=8 && blue<=5){
    analogWrite(L_PWM, 0);
    analogWrite(R_PWM, 255);
    digitalWrite(BACK_LED, HIGH);
    digitalWrite(FRONT_LED, HIGH);
    delay(600000);
  }//motor runs block
  else{
    int j;
    for(j=0;j<255;j++){
      analogWrite(R_PWM, 0);
      analogWrite(L_PWM, 255);
      digitalWrite(FRONT_LED, HIGH);
    }
  }
}```

This is our code. We are doing a simple small car. it goes and if rgb sensor sees a color change car stops. We are using 12V car battery for testing, is it working or not.

everything is fine with it but we should do a chemical battery(Al-Air battery). we can reach 15V or 25V it is up to us. but i think the problem is amper because when we use chemical battery the car is not running. even arduino leds not lighting. i want to calculate what is our requirements.

Here they are:

This is our code. We are doing a simple small car. it goes and if rgb sensor sees a color change car stops. We are using 12V car battery for testing, is it working or not. everything is fine with it but we should do a chemical battery(Al-Air battery). we can reach 15V or 25V it is up to us. but i think the problem is amper because when we use chemical battery the car is not running. even arduino leds not lighting. i want to calculate what is our requirements.

You have a pin conflict. You are using Arduino Pin 1 for PWM of your motor driver. It is not a PWM pin. If you are connecting your computer the the USB port, Pin 1 is being used by the Serial Monitor. Also, Arduino Pin 4 is not a PWM pin. Search "arduino uno pinout" for pin usage.

These are the PWM pins of Arduino UNO:
pwm328x

I moved your topic to an appropriate forum category @tolgabtw .

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

@tolgabtw Welcome to the forum!

I note you're not making use of the digital capabilities of the Analog pins (A0..A5). You can move your LEDs over to those pins, which will allow you to free up pins 0 and 1 for Serial Monitor use. As you become more familiar with Arduinos, you'll want to keep Serial Monitor running almost always.

I changed the PWM pins thanks for that but still dont know how much ampers we need. because we can make 25V battery but it doesnt move the motor.

Since the major user of current is your motor, measure the resistance of the motor connection and use Ohm's law to calculate the current it will use when connected to either battery.

I read a warning about maximum ampere and heat dissipation... if you run the BTS7680 near its maximum current (43A), you need another heat sink directly on the top of the I.C.s

Aluminium–air batteries are primary cells, i.e., non-rechargeable. Once the aluminium anode is consumed by its reaction with atmospheric oxygen at a cathode immersed in a water-based electrolyte to form hydrated aluminium oxide, the battery will no longer produce electricity.
The hydrated alumina that is created by the cell reaction forms a gel-like substance at the anode and reduces the electricity output.

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