qoistoochee128

Single mos four-way control motherboard

 
Overview

Go directly to the code and test it. There is no explosion or fire. Note that this is the video received from the receiver. The first speed is about 1/4 of the full speed. Later, a better control motherboard will be released.  IMG_20200917_214010.jpgIf you don’t have Arduino basics, don’t do it. IMG_20200917_090735.jpg


#define PINX 11
#define PINY 2
#define PINKG 7
#define LEDA 12
#define LEDB 13

#define PINLU 5
#define PINLD 6
#define PINRU 10
#define PINRD 9

int TZ=40;//速度调整
int speedcal=0;

int Direction;//方向原始数据
int correctionXR;//x修正后的X
int correctionXL;//x修正后的X
int spd=255;
unsigned long Speed;
unsigned long KGSG;
void motorprint();
void motorcontrol();
void dealX();//X方向调整

void motorprint()
{
  pinMode(PINX, INPUT); //设置引脚为输入模式
  pinMode(PINY, INPUT); //设置引脚为输入模式
  pinMode(PINKG, INPUT); //设置引脚为输入模式
  pinMode(8, INPUT); //设置引脚为输入模式

//    pinMode(PINLU, OUTPUT); //设置引脚为输出模式
    pinMode(PINLD, OUTPUT); //设置引脚为输出模式
    pinMode(PINRU, OUTPUT); //设置引脚为输出模式
//    pinMode(PINRD, OUTPUT); //设置引脚为输出模式

//    digitalWrite(PINLU,LOW);
    digitalWrite(PINLD,LOW);
    digitalWrite(PINRU,LOW);
//    digitalWrite(PINRD,LOW);

    pinMode(LEDA, OUTPUT); //设置引脚为输出模式
}

void motorcontrol()
{
  if (Direction>TZ/2+3)
  {
       speedcal=constrain(map((Speed+Direction),Speed,310,Speed,250),Speed,250);
//     analogWrite(PINLU,speedcal);
       analogWrite(PINLD,speedcal);
       analogWrite(PINRU,Speed);
//     analogWrite(PINRD,Speed);
  }
  else if (Direction<TZ/2-3)
  {
      speedcal=constrain(map((Speed+Direction),Speed,310,Speed,250),Speed,250);
//    analogWrite(PINLU,Speed);
      analogWrite(PINLD,Speed);
      analogWrite(PINRU,speedcal);
//    analogWrite(PINRD,speedcal);
  }
  else
  {
//    analogWrite(PINLU,Speed);
    analogWrite(PINLD,Speed);
    analogWrite(PINRU,Speed);
//    analogWrite(PINRD,Speed);
  } 

}

void setup()
{
  Serial.begin(19200);
  motorprint();
}

void loop()
{

  /*Speed =pulseIn(Y, HIGH,80000);
Direction =pulseIn(X, HIGH,80000);
 KGSG = pulseIn(KG, HIGH,80000);*/
  KGSG = pulseIn(PINKG, HIGH,80000);
  if(KGSG<1100)
  spd=3;
  else if(KGSG<1700)
  spd=2;
  else if(KGSG<2000)
  spd=1;
  else
  spd=255;

  Speed=(constrain(map(pulseIn(PINY, HIGH,80000),989,1968,0,240), 0, 240)/spd);
  Direction =constrain(map(pulseIn(PINX, HIGH,80000),998,1982,0,TZ),0,TZ); 
  if (pulseIn(8, HIGH,80000)<1500)
  {
  digitalWrite(LEDA,HIGH);
  TZ=70;}
  else{
  digitalWrite(LEDA,LOW);
  TZ=50;}

/*  Serial.print("速度:");
  Serial.print(Speed);
  Serial.print(" 方向:");
  Serial.print(Direction);
  Serial.print(" 控制:");
  Serial.println(KGSG);*/
  if (Speed<10)
  {
    Speed=0;
    motorcontrol();
  }
  else
   motorcontrol();
} 
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-09 08:13:42

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号