Go Down

Topic: the first code any arduino beginner should see (Read 1 time) previous topic - next topic

Englishscone

Code: [Select]


void setup() {//this function runs forever
  pinMode(LED_BUILTIN, OUTPUT);//this configure the pin for sensor input
}
//white space increased the speed of the code, the more the better

void loop() { //this function runs only once
  digitalWrite(LED_BUILTIN, HIGH);//this sets the pin in a sensor input low impedance mode
  delay(1000);//this is a delay to wait(in minutes)
  digitalWrite(LED_BUILTIN, LOW);//this sets the pin as an output to run high current things like motors
  delay(1000 );//same as above, but because a space is inside the parentheses the value is multiplied by 2.4
}//this tells the arduino to repeat the code 3 more times

MAS3

To me the he joke is not very funny.
You want to show new people some code full of incorrect comments ?
Not a single comment is correct, and there's a lot of them.
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Robin2

To me the he joke is not very funny.
+1

Always keep in mind that the Forum will be read by people without experience - after all they are our principal customers.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

larryd

{ and }  prevents the code from spilling onto the floor.



No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

TheMemberFormerlyKnownAsAWOL

Should this be part of the "Priceless in a really sad way" topic?
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

Englishscone

sorry everyone this was just a joke but yeah you all are right

GaryP

Don't worry, sometimes ideas inside your head just don't work so well in real life. Been there and done that more than one man should...

Cheers,
Kari
The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Qdeathstar

A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.

Englishscone

Don't worry, sometimes ideas inside your head just don't work so well in real life. Been there and done that more than one man should...

Cheers,
Kari

Thanks for the encouragement!

dmjlambert

I have thought about the blink sketch, which is probably the first code beginners normally see.   It would be better if the official example blink sketch were replaced with a simple as possible and properly commented blink without delay in the Arduino IDE distribution.   My first exposure to programming was back when goto was in style, and although available in many programming languages it is just not used any more, and new users are not introduced to it.   The same treatment could be done with delay. 

GoForSmoke

I think of the number of times I've corrected mistakes stemming from the BWD example, using signed variables to work with time and that's just over one goofball mistake.

Please don't make it worse! Some people get an idea and cling to it like a loyalty oath, all evidence to the contrary becomes some kind of personal fight.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

jimLee

If there were a simple threading model built in, they could be introduced to "sleep()" and go off to do something else?

-jim lee
PNW Ardiuno & Maker club
1012 9Th Street, Anacortes, WA 98221 (Around the back of building)

GoForSmoke

Introduce them to workToLearn() and see how many don't sleep() instead.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Go Up