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
}
gcjr
April 23, 2021, 10:36am
2
harshith_mh:
uint8_t[8] = {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
press Ctrl-T for autoformatting your code
do a rightclick with the mouse and choose "copy for forum"
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;
See also FAQ - Arduino Forum for general rules on forum behaviour and etiquette.
Hello,
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is fru…
Thanks.. Tom..
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
}
6v6gt
April 24, 2021, 6:40am
6
harshith_mh:
uint8_t(8) = {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..
system
Closed
August 22, 2021, 7:11am
8
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.