Hello.I am newbee with arduino and programming,I bought the starter kit and I try to verify the project (keyboard) from starter kit book ,but there is an error in second line ,I copy the code from book exactly the same but I can't find the error.Can anyone find the error?
Thank you in advance
Yeah thanosxx, every symbol in code must be exact. Much of the time spent debugging code is finding mistypes. With practice you get faster and you make fewer of these kind of errors but only on very simple code does everything go right first time.
You are okay, this happens to us all. The way you learn to think is closer to algebra than spoken words where close is enough. With spoken words the listener has a mind, with computer code there is only a machine to set up to run.
FYI, there's no need to type in the code from the book. All the code is included with the Arduino IDE at File > Examples > 10.StarterKit_BasicKit. Invest the time you would have wasted typing and debugging your typos in studying each line of code and researching/experimenting until you understand what each does and you'll be far ahead in your learning process.
Yes.I compare the code with example of starter kit and it is different, on starter kit book ,before SETUP function there is 3 int,and I have problem with second line,but in software on (FILES examples ,starter kit there is only one before setup)
thanosxx:
on starter kit book ,before SETUP function there is 3 int
You mean these extra two lines from the sketch you attached to your post:
int buttons[6];
int buttons[0]=2;
This is an example of why it's important to take the time to study the code instead of just blindly typing it out. Then you might understand why it would make sense to either add or remove those two lines instead of seeing them as inscrutable parts of a magical incantation.
Hello again.As newbie I start with the starter kit and I am reading the book for a general knowledge about arduino and create all project ,then I am thinking go back to start of book and I will try to create simply code (with a led)until understand ,how create a code but for now I have stuck in this project and in this point
thanosxx:
Yes.I compare the code with example of starter kit and it is different, on starter kit book ,before SETUP function there is 3 int,and I have problem with second line,but in software on (FILES examples ,starter kit there is only one before setup)
I can't get to my Arduino IDE and internet at the same time (old PC and OS+apps choices), I can't see your post and that code at the same time.
Every new IDE has versions of examples that fit that version. The starter book was published on some date but the IDE may have updated code. Did you try loading the keyboard example from the IDE?
You haven't posted enough code to tell us what your problem might be.
thanosxx:
Hello again.As newbie I start with the starter kit and I am reading the book for a general knowledge about arduino and create all project ,then I am thinking go back to start of book and I will try to create simply code (with a led)until understand ,how create a code but for now I have stuck in this project and in this point
int buttons[0]=2;
You might be right. That line seeks to make an array of int variables with zero members and then set it to 2!
Knowledge is power. You need more until your view is clear.
The Arduino Language Reference Page, you might want to keep this open in a browser tab while you use the IDE. It will make checking code quicker and easier. I note the /en/ at the end, there must be versions in not-english.
Good luck. If your head gets tired, take a break right then! It is easy to become fixated on some detail and not see anything else, like answers and then you hit a point where you don't know what's wrong --- from there it is stay and push harder which will burn you out or get away and come back with fresh eyes that see beyond the earlier tight focus.
The human brain grows 'knowledge' in response to stimuli. Sometimes that takes longer than we want.
That snippet does not make sense. You are defining an array that can hold 0 elements, and then using the wrong syntax to store data in the array, which wouldn't fit if you used the correct syntax.
There's a lot of research on how we learn. Most of it seems to agree that we don't actually retain anything until we've slept. So, this is excellent advice. Take a break; take a nap. You'll retain a lot more.
PaulS:
There's a lot of research on how we learn. Most of it seems to agree that we don't actually retain anything until we've slept. So, this is excellent advice. Take a break; take a nap. You'll retain a lot more.
James Burke did an excellent and entertaining series in 1980 titled The Real Thing that goes into neuro to explain about wetware. Through 5 programs he builds a picture of how things work (to then knowledge, including a scanning micrograph of a neuron growing a connection) but shouldn't and then is the 6th one that introduces language. A poor copy is up on youtube but the content isn't lost.
pert:
You mean these extra two lines from the sketch you attached to your post:
int buttons[6];
int buttons[0]=2;
If it was not clear enough, these lines are not part of the sketch.
This is a an example on how to use arrays and the second line is wrong in the book, it should not have the "int" there.
thanosxx, in the future, please post code directly to the forum whenever possible. This will make it more easily accessible to all forum members and thus you will have a better chance of getting help. The forum does have a limit of 9000 characters and if your code exceeds that limit it's fine to post it as an attachment. In this case you are nowhere near 9000 characters.
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags: [code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.
Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you're using the Arduino Web Editor you will not have access to this useful tool but it's still unacceptable to post poorly formatted code. I recommend you to use the standard IDE instead.