1st code

I have been playing around with Ardunio because I have no internet and I have to be in my room for 10:30 in this hostel, so I have a couple of hours alone each night and I have always wanted to get into programming. I figured Arduino would be easy to learn, then I could learn a bit of Java etc.

I looked over some of the examples to start out. I looked through the basic and digital examples a bit for 2 nights and I wanted to try making something myself so I could see if I was ready to buy a board.

Could you look over my code and see if I did it right? I just want to know what I did wrong and what I can do to make this better (I was thinking about replacing the print button to a knock sensor or something too). I attached one with notes that I used (I didn’t want to forget what I did the next day because I made this at 1am) and another without the notes.

Thanks.

_3_Lights_with_notes.ino (2.85 KB)

_3_Lights.ino (169 Bytes)

Even with no hardware, you can download the Arduino IDE and compile your code. If you do this you will find a number of simple errors. Variables cannot start with a number. So on line 27 change: const int 1ButtonPin = 2; to const int ButtonPin1 = 2;

Same for lines 28, 29. On line 58, bledPin is not defined. You meant BledPin. 1buttonState (line 36) is not defined, nor is 2buttonState or 3buttonState.

Most of these are just syntax errors that the compiler will find for you.

-transfinite

How do you intend to get the code onto the Arduino without using the IDE?

If you do have the IDE, why didn't you at least compile the code you posted?

transfinite: Even with no hardware, you can download the Arduino IDE and compile your code. If you do this you will find a number of simple errors. Variables cannot start with a number. So on line 27 change: const int 1ButtonPin = 2; to const int ButtonPin1 = 2;

Same for lines 28, 29. On line 58, bledPin is not defined. You meant BledPin. 1buttonState (line 36) is not defined, nor is 2buttonState or 3buttonState.

Most of these are just syntax errors that the compiler will find for you.

-transfinite

I do have the IDE but it gives me errors when I try to compile even the example code. I copied the blink example word for word on the 1st day and it gave me an error when I tried to compile, so I tried to compile the example and it gave an error there too so I wanted to ask if I had errors here instead.

And should I label the buttons and leds with letters instead of numbers, or just put the number at the end like "const int ButtonPin1" and I will try changing the 1/2/3buttonState to just buttonState.

It sounds like you need to uninstall and reinstall the IDE. All the examples should compile without errors.

The names of your variables or labels are up to you as long as the variables don't start with a number.

-transfinite

First of all , the IDE is not like a normal install program where you double click once and it starts a process that pops up windows to which you just click "next" or "ok". It's not like that at all. It's really nothing more than a bunch of files you unzip an put somewhere. If you look at the Arduino download page it doesn't ever tell you where the files are supposed to go. The IDE is an executable that will execute no matter where it is but it won't work if the Arduino folder isn't where it should be. So where is it ? How did you know where to put it ? (I know where it belongs but I want to hear your answer(

raschemmel: First of all , the IDE is not like a normal install program where you double click once and it starts a process that pops up windows to which you just click "next" or "ok". It's not like that at all. It's really nothing more than a bunch of files you unzip an put somewhere.

That does depend on what you install: If you look at http://arduino.cc/en/Main/Software#toc2 you'll see a full-blown Windows installer as well as the zip file you are talking about.

Regards,

Brad KF7FER