Commit b0bd60e0 authored by 957dd's avatar 957dd

更新了坦克代码占用pwm引脚的问题

parent 2b8c9f58
No preview for this file type
...@@ -35,15 +35,22 @@ void pin_all_default()//全部至低电平 ...@@ -35,15 +35,22 @@ void pin_all_default()//全部至低电平
void pin_value(int pin,int value) void pin_value(int pin,int value)
{ {
if(value==1) if(pin==2){
{ pinMode(pin, OUTPUT);
digitalWrite(pin, HIGH);
}if(pin==21){
pinMode(pin, OUTPUT);
} }
else if(value==0)
{ if(value==1){
digitalWrite(pin, HIGH);
printf("pin:%d,%d\n",pin,HIGH);
}else if(value==0){
digitalWrite(pin, LOW); digitalWrite(pin, LOW);
printf("pin:%d,%d\n",pin,LOW);
} }
printf("pin:%d,%d\n",pin,value);
} }
void pwm_speed() { void pwm_speed() {
......
No preview for this file type
...@@ -118,8 +118,6 @@ void message_3(cJSON *body,cJSON *pwm_ctrl)//message_type为3,控制pwm ...@@ -118,8 +118,6 @@ void message_3(cJSON *body,cJSON *pwm_ctrl)//message_type为3,控制pwm
void message_4(cJSON *body, cJSON *pin_setctrl)//message 为4时候 void message_4(cJSON *body, cJSON *pin_setctrl)//message 为4时候
{ {
cJSON *pin = cJSON_GetObjectItem(pin_setctrl, "pin"); cJSON *pin = cJSON_GetObjectItem(pin_setctrl, "pin");
cJSON *val = cJSON_GetObjectItem(pin_setctrl, "val"); //val为pwm的值 0~100(unsigned char)(unsigned char) cJSON *val = cJSON_GetObjectItem(pin_setctrl, "val"); //val为pwm的值 0~100(unsigned char)(unsigned char)
pinTemp=pin->valueint; pinTemp=pin->valueint;
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment