Can Somone Help Me Please!

I wrote a code but I got unexpected error : (Line 1) expected identifier before numeric constant. I am a newbie so can somone tell me what correction to make

uint8_t[8] = {0} ;

int Xpin = A0;
int Ypin = A1;
int X;
int Y;

void setup() {
// put your setup code here, to run once:
pinMode(Xpin, INPUT);
pinMode(Ypin, INPUT);
}

void loop() {
// put your main code here, to run repeatedly:
if (analogRead(Xpin) > 980){
buf[2] = 4;
keyRelease();
}

if (analogRead(Xpin) < 500){
buf[2] = 7;
keyRelease();
}

if (analogRead(Ypin) > 980){
buf[2] = 22;
keyRelease();
}

if (analogRead(Ypin) > 500){
buf[2] = 26;
}
}
keyRelease();
}

if (analogRead(Xpin) > 980){
buf[2] = 26;
keyRelease();
}

}

void keyRelease(){
buf[0] = 0
buf[2] = 0
}

you specify a variable type, uint8_t, but no variable name

You should post code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

best regards Stefan

Hi, @harshith_mh
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

To add code please click this link;

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

Thankyou! Here's the code:

int Xpin = A0;
int Ypin = A1;
int X;
int Y;



uint8_t(8) = {0} ;




void setup() {
  // put your setup code here, to run once:
  pinMode(Xpin, INPUT);
  pinMode(Ypin, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (analogRead(Xpin) > 980) {
    buf[2] = 4;
    keyRelease();
  }

  if (analogRead(Xpin) < 500) {
    buf[2] = 7;
    keyRelease();
  }

  if (analogRead(Ypin) > 980) {
    buf[2] = 22;
    keyRelease();
  }

  if (analogRead(Ypin) > 500) {
    buf[2] = 26;
  }
}
keyRelease();
}

if (analogRead(Xpin) > 980) {
  buf[2] = 26;
  keyRelease();
}

}

void keyRelease() {
  buf[0] = 0
           buf[2] = 0
}

You have already been told that this is incorrect.

it should be something like:

uint8_t myArray[ 8 ] = { 0 } ;   // define a byte array with 8 elements called myArray

since you are using the array buf[] in your code, but have not defined it, I guess that was an attempt to define buf[]

Hi, @harshith_mh

Can you tell us what you want your code to do and what hardware are you using, including model Arduino.

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

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