类型“ int *”的错误参数与类型“ uint8_t”的参数不兼容

如何解决类型“ int *”的错误参数与类型“ uint8_t”的参数不兼容

这是我第一次编码。我刚刚从youtube.com上学到了一些东西,这是我第一次使用这些知识为我的微控制器编写arduino草图。请放轻松我。

我遇到的问题是:

* “ int ”类型的参数与“ uint8_t”类型的参数不兼容

它在OUTPUT数组声明中。

Error Screenshot

Error areas 1 and 2 Error area 3

await page.waitForTimeout(5000);

解决方法

在许多定义中,类型都不正确:

bool J5 = 19;
...
bool J1 = 17;
...
int J3in = 2;
int J3state;

bool J4 = 14;
bool J3out = 18;

int C1[4] = {10,11,13,4};
int C2[3] = {11,12,4};
int C3[2] = {10,4};
int C4[1] = {9};
int C5[1] = {8};

xxstate指示器的类型应为bool,而其他声明的类型应为uint8_t

,

这是修改后的代码。它解决了先前的问题(可能是因为我丢弃了数组,这不是一个解决方案,但对我有用)。

#include <Arduino.h>
#include <avr/sleep.h>                                     // this AVR library contains the methods that controls the sleep modes

bool RSTstate = 0;
  //Inputs and their Variables
  int J5 = 19;                          //J5 is also an boolerrupt so we are going to be using that as one too.
  bool j5state;
  
  
  //Inputs PULLUPs
  const int S3 = 0;
  const int S1 = 1;
  bool S1state;
  bool S3state;
  
  //Momentary PULLUPs
  const int J1 = 17;
  bool j1state;

  //Analog Inputs
  const int J3in = 2;
  int J3state;
  
  //Momentary OUTPUTs 
  const int J4 = 14;
  const int J3out = 18;

  //OUTPUTs
  const int C123 = 4;
  const int C1 = 13;
  const int C12 = 11;
  const int C13 = 10;
  const int C2 = 12;
  const int C4 = 9;
  const int C5 = 8;

  /*
  int C1[4] = {10,4};
  int C2[3] = {11,4};
  int C3[2] = {10,4};
  int C4[1] = {9};
  int C5[1] = {8};
  */


void goingToSleep() {
  sleep_enable();                                          // enabling sleep mode
  attachInterrupt(j5state,wakeUp,LOW);                   // attaching to boolerrupt J5 (INTERRUPT_PIN) the function wakeUp to be triggered when get LOW signal... Also J5 LOW means plugged IN.
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);                     // setting the sleep mode,in our case full sleep
  sleep_cpu();                                             // activating sleep mode
}

void wakeUp() {
  Serial.println("boolerrrupt Fired!");                     // print message to serial monitor
  sleep_disable();                                         // disable sleep mode
  detachInterrupt(j5state);                               // removes the boolerrupt from J5
  softreset();              //Now needs to reset the mcu as the jack is plugged in.
}

void softreset() {
  asm volatile ("  jmp 0");    //Just restart the sketch,does not reset the registers etc.
}

void setup() {
  pinMode(J5,INPUT);
  pinMode(S3,INPUT_PULLUP);
  pinMode(S1,INPUT_PULLUP);
  pinMode(J1,INPUT);
  pinMode(J3in,INPUT);
  pinMode(C1,OUTPUT);
  pinMode(C12,OUTPUT);
  pinMode(C13,OUTPUT);
  pinMode(C123,OUTPUT);
  pinMode(C2,OUTPUT);
  pinMode(C4,OUTPUT);
  pinMode(C5,OUTPUT);
  Serial.begin(9600);
  //First turn off every output
  digitalWrite(C1,LOW);
  digitalWrite(C12,LOW);
  digitalWrite(C123,LOW);
  digitalWrite(C13,LOW);
  digitalWrite(C2,LOW);
  digitalWrite(C4,LOW);
  digitalWrite(C5,LOW);
  //This is the first phase: To check if the headphone plug is connected or not.
  pinMode(J4,OUTPUT);
  digitalWrite(J4,LOW);
  delay(5);
  j5state = digitalRead(J5);
  if (j5state == LOW) { //That means that the 3.5mm plug is put in.
    //Here the second phase starts where we need to check the connectivity of S1 and S3.
    pinMode(J4,INPUT);       //Fisrt setup the J4 to INPUT so that it does not boolerface with the Audio.
    S1state = digitalRead(S1);
    S3state = digitalRead(S3);
    if (S1state == HIGH && S3state == LOW) { //This means that Condition 1,2 and 3 applies.
      //Here is the 3rd phase starts where we have to check the conditions for C1,C2 and C3
      //First C1 where we have to check for J1 and J2 connectivity. J2 is Hardware GND and J1 is mic input which is boolernal PULLUP.
      pinMode(J1,INPUT_PULLUP);
      delay(5);
      j1state = digitalRead(J1);
      if (j1state == LOW) {
        //This is where the C1 condition is TRUE and is executed
        digitalWrite(C1,HIGH);
        digitalWrite(C123,HIGH);
        digitalWrite(C12,HIGH);
        digitalWrite(C13,HIGH);
      }
      else if (j1state == HIGH) {
        //That means C1 is not meeting requirements and thus C2 is now checked
        //To check C2 we need to check between J3 and J4 and the easy way to do that is to just check an analog value for J3 to GND.
                pinMode(J3in,INPUT);
                pinMode(J3out,OUTPUT);
                delay(5);
                digitalWrite(J3out,HIGH);
                delay(5);
                J3state = analogRead(J3in);
                pinMode(J3out,INPUT);
                if (J3state > 15) {
                    //That means that J3 is not connected to GND. Which means there is a speaker attached. That means C2 is applied.
                    digitalWrite(C2,HIGH);
                    digitalWrite(C123,HIGH);
                    digitalWrite(C12,HIGH);
                }
                else if (J3state < 15) {
                  //That means that J3 is directly connected to GND which also means that there is no speaker attached.
                  //So now C3 is applied.
                  digitalWrite(C123,HIGH);
                  digitalWrite(C13,HIGH);
                }
                else {
                  Serial.println("ERROR C2,C3");
                }
      }
      else {
        Serial.println("ERROR C1");
      }
    }
    else if (S1state == LOW && S3state == HIGH) {
      //Now the S1 is turned ON and thus we only need to check Condition 4 (C4) and C5.
      //First C4,for C4 we need the connection between J3 and GND. Same method as C2 and C3.
      pinMode(J3out,OUTPUT);
      delay(5);
      digitalWrite(J3out,HIGH);
      delay(5);
      J3state == analogRead(J3in);
      pinMode(J3out,INPUT);
      if (J3state > 15) {
        //That means J3 is not connected to GND. Which applied C4.
        digitalWrite(C4,HIGH);
      }
      else if (J3state < 15) {
        //Now the condition is set to C5
        digitalWrite(C5,HIGH);
      }
      else {
        Serial.println("ERROR C4,C5");
      }
    }
    else {
      Serial.println("ERROR S1,S3");
    }
  }
  else if (j5state == HIGH) {
    goingToSleep();    
    //This loop is for when there is no jack,the microcontroller can just
    //wait for the plug to be inserted. But also in some kind of sleepmode to conserve power.    
  }
  else {
    Serial.println("ERROR JACK");
  }
  }
//All of the above process is done in the setup loop since it does not needs to be repeated. Only run once.


void loop() {
  if (RSTstate == 1){
    softreset();
  }
  else {
    goingToSleep();     //Once everything is executed succesfully. Here the microcontroller goes boolo sleep mode and will only wake up if the jack is plugged IN again.
  }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-