Lesson 1: Blink
עמוד זה דורש דפדפן עדכני (תומך ב-SharedArrayBuffer). אנא עדכן את Chrome, Edge, Firefox או Safari לגרסה העדכנית ביותר.
English
Meet the Arduino
- An Arduino Uno is a small computer on a board. It has pins: little holes for wires.
- Your program is called a sketch. Press Run: the server turns it into machine code, and the board on this page runs it.
- This is real Arduino code. The same sketch works on a real board at school or at home.
Words for this lesson
| Word | Meaning |
|---|---|
| pin | a connection on the board, with a number (pin 13) |
| OUTPUT | the pin sends power out, for example to an LED |
| HIGH / LOW | on (5 volts) / off (0 volts) |
| delay | wait; delay(1000) waits 1000 milliseconds = 1 second |
English
setup and loop
- Every sketch has two parts.
setup()runs once when the board starts.loop()runs again and again, for ever.
void setup() {
pinMode(13, OUTPUT); // pin 13 sends power out
}
void loop() {
digitalWrite(13, HIGH); // LED on
delay(1000); // wait 1 second
digitalWrite(13, LOW); // LED off
delay(1000);
}
- Press Run. The LED on pin 13 blinks: one second on, one second off.
- Every line ends with
;. Upper and lower case matter:HIGH, nothigh.
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
Make the LED on pin 13 blink faster: on for 250 ms, then off for 250 ms, again and again.
לחץ על הרץ כדי לראות את התוצא כאן.
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
Make a heartbeat: the LED on pin 13 is on for 100 ms, then off for 900 ms, again and again.
לחץ על הרץ כדי לראות את התוצא כאן.