Microsoft Store β press Install. Installer (.exe) β open the downloaded file and click I Agree β Install, then Finish.
2
Open Arduino IDE (it may take a minute the first time).
3
Plug the board into the computer: the square (USB-B) end into the board, the flat (USB-A) end into the computer. A little green power light turns on.
4
In Arduino IDE: Tools β Board β Arduino AVR Boards β Arduino Mega or Mega 2560. If it offers to install βArduino AVR Boardsβ, click Install.
5
Tools β Port β pick the port that appeared (something like COM3).
π οΈ No COM port showing up?
Most ELEGOO boards use a chip called CH340 that Windows needs a small driver for. Find the CH340 driver in your kit's download folder (or search βCH340 driver Windowsβ), install it, then unplug and replug the board and check Tools β Port again.
1
Make the Light Blink
β Your first program
π― Upload your very first program and make the tiny built-in light blink β then make it blink your way.
Parts Needed
π Mega2560 + USB cableβ¨ That's it!
Wiring
No wiring needed β the Mega2560 has a small LED built in, already wired to pin 13.
The Code
// Experiment 1 β Blink
// Pin 13 has a tiny LED soldered onto the board.
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // get pin 13 ready to send power
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // LED ON (HIGH = 5 volts)
delay(1000); // wait 1000 ms = 1 second
digitalWrite(LED_BUILTIN, LOW); // LED OFF (LOW = 0 volts)
delay(1000); // wait 1 second
}
1
In Arduino IDE, delete anything in the editor and type (or paste) the code above.
2
Click the round β Upload button (top-left). Wait for βDone uploading.β
3
Watch the board β the little LED blinks on for 1 second, off for 1 second. π
π¬ How it works
setup() runs once when the board powers on. loop() runs over and over forever. digitalWrite turns a pin ON (HIGH) or OFF (LOW), and delay pauses in milliseconds (1000 = one second).
π§ͺ Try this
Change both 1000s to 200 and upload again β fast blink! Then make an SOS signal: 3 quick blinks, 3 slow blinks, 3 quick blinks.
2
A Button Switch
β β Input + Output
π― Wire up a real LED and a push button. Press the button β light ON. Let go β light OFF.
π Show realistic breadboard layout (Fritzing-style)
Holes in the same column (within one half) are joined inside the board. The button bridges the center gap; both green jumpers go to the blue (β) GND rail.
// Experiment 2 β Button switch
const int buttonPin = 2; // the push button
const int ledPin = 8; // the LED
void setup() {
pinMode(buttonPin, INPUT_PULLUP); // built-in resistor; pressed = LOW
pinMode(ledPin, OUTPUT);
}
void loop() {
if (digitalRead(buttonPin) == LOW) { // button is pressed
digitalWrite(ledPin, HIGH); // light ON
} else {
digitalWrite(ledPin, LOW); // light OFF
}
}
π¬ How it works
digitalReadchecks a pin instead of powering it. INPUT_PULLUP uses a resistor inside the chip so the pin reads HIGH normally, and LOW when you press the button (which connects it to GND). The if / else makes a decision every loop.
π§ͺ Try this
Turn it into a toggle: press once to turn on, press again to turn off. (Hint: you'll need a variable that remembers if the light is on, and you only flip it the moment the button is first pressed.)
3
Breathing Light
β β β PWM & loops
π― Make the LED smoothly fade brighter and dimmer, like it's slowly breathing.
π Show realistic breadboard layout (Fritzing-style)
Same single LED branch as Experiment 2 β just move the orange wire to Pin 9 (~) so it can fade. The green jumper goes to the blue (β) GND rail.
π Wiring in words
Same as before, but the LED's resistor now connects to Pin 9 (a pin with a ~ next to it). LED short leg (β) β GND.
The Code
// Experiment 3 β Breathing light (PWM)
const int ledPin = 9; // pin 9 has a "~" (can fade)
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
// fade up: 0 (off) to 255 (full brightness)
for (int b = 0; b <= 255; b++) {
analogWrite(ledPin, b);
delay(6);
}
// fade down: 255 back to 0
for (int b = 255; b >= 0; b--) {
analogWrite(ledPin, b);
delay(6);
}
}
π¬ How it works
analogWrite uses a trick called PWM: it flicks the pin on and off super fast, so the LED looks dimmer or brighter β any value from 0 to 255. A for loop counts for you, so you don't write 256 separate lines.
π§ͺ Try this
Make the delay(6) bigger for slow, sleepy breathing or smaller for fast. Bonus: add a second LED on another ~ pin that fades the opposite way.
4
Smart Night Light
β β β β Sensors & Serial Monitor
π― Use a light sensor so the LED brightens when the room gets dark and dims when it's bright β all by itself. Then watch the numbers live on screen.
// Experiment 4 β Smart night light
const int sensorPin = A0; // the light sensor
const int ledPin = 9; // LED on a "~" pin
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600); // open a line to the computer
}
void loop() {
int light = analogRead(sensorPin); // 0 = dark ... 1023 = bright
int brightness = map(light, 0, 1023, 255, 0); // darker -> brighter LED
analogWrite(ledPin, brightness);
Serial.println(light); // print the reading
delay(50);
}
1
Upload the code, then open Tools β Serial Monitor and set it to 9600 baud (bottom-right).
2
Cover the sensor with your hand β the number drops and the LED gets brighter.
3
Shine a phone light on it β the number rises and the LED dims.
π¬ How it works
analogRead turns the sensor's voltage into a number from 0 to 1023. map rescales one range to another (here, flipping it so dark = bright LED). Serial.println sends data back to the computer so you can see what the board senses.
π§ͺ Try this
Watch your room's numbers, pick a βdarkβ value, then add an if so the LED only switches on below that number β a real automatic night light that ignores small changes.
β οΈ Lab Rules
Always put a resistor in line with an LED β a bare LED on 5V can burn out.
Build and rewire with the USB unplugged; plug it in only when you're ready to test.
Never connect 5V straight to GND β that's a short circuit.
LED legs: the long leg is + (anode); the short leg / flat side is β (cathode).
Push pins and wires in gently, and keep drinks away from the breadboard.
π My Progress
#
Experiment
Level
Done?
0
Get Set Up
β
1
Make the Light Blink
β
2
A Button Switch
β β
3
Breathing Light
β β β
4
Smart Night Light
β β β β
Print this page and tick a box each time you finish. Keep tinkering! π§